LABORATORY MANUAL. ADVANCED EMBEDDED SYSTEMS M. Tech I Year II Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

Size: px
Start display at page:

Download "LABORATORY MANUAL. ADVANCED EMBEDDED SYSTEMS M. Tech I Year II Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG."

Transcription

1 LABORATORY MANUAL ADVANCED EMBEDDED SYSTEMS M. Tech I Year II Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG. BALAJI INSTITUTE OF TECHNOLOGY & SCIENCE Laknepally, Narsampet, Warangal 1

2 LIST OF EXPERIMENTS Note: A. The following programs are to be implemented on ARM based Processors/Equivalent. B. Minimum of 10 programs from Part I and 6 programs from Part -II are to be conducted. PART- I: The following Programs are to be implemented on ARM Processor 1. Simple Assembly Program for a. Addition Subtraction Multiplication Division b. Operating Modes, System Calls and Interrupts c. Loops, Branches 2. Write an Assembly programs to configure and control General Purpose Input/Output (GPIO) port pins. 3. Write an Assembly programs to read digital values from external peripherals and execute them with the Target board. 4. Program for reading and writing of a file 5. Program to demonstrate Time delay program using built in Timer / Counter feature on IDE environment 6. Program to demonstrates a simple interrupt handler and setting up a timer 7. Program demonstrates setting up interrupt handlers. Press button to generate an interrupt and trace the program flow with debug terminal. 8. Program to Interface 8 Bit LED and Switch Interface 9. Program to implement Buzzer Interface on IDE environment 10. Program to Displaying a message in a 2 line x 16 Characters LCD display and verify the result in debug terminal. 11. Program to demonstrate I2C Interface on IDE environment 12. Program to demonstrate I2C Interface Serial EEPROM 13. Demonstration of Serial communication. Transmission from Kit and reception from PC using Serial Port on IDE environment use debug terminal to trace the program. 14. Generation of PWM Signal 15. Program to demonstrate SD-MMC Card Interface. PART- II: Write the following programs to understand the use of RTOS with ARM Processor on IDE Environment using ARM Tool chain and Library: 1. Create an application that creates two tasks that wait on a timer whilst the main task loops. 2. Write an application that creates a task which is scheduled when a button is pressed, which illustrates the use of an event set between an ISR and a task 3. Write an application that Demonstrates the interruptible ISRs(Requires timer to have higher priority than external interrupt button) 4. a).write an application to Test message queues and memory blocks. b).write an application to Test byte queues 5. Write an application that creates two tasks of the same priority and sets the time slice period to illustrate time slicing. Interfacing Programs: 6. Write an application that creates a two task to Blinking two different LEDs at different timings 7. Write an application that creates a two task displaying two different messages in LCD display in two lines. 8. Sending messages to mailbox by one task and reading the message from mailbox by another task. 9. Sending message to PC through serial port by three different tasks on priority Basis. 10. Basic Audio Processing on IDE environment. 2

3 1. Simple Assembly Program for a. Addition Subtraction Multiplication Division b. Operating Modes, System Calls and Interrupts c. Loops, Branches Addition of 4 numbers : Total = A+B+C+D Program: start MOV r0, r1; Make the first number the subtotal ADD r0, r0, r2; Add the second number to the subtotal ADD r0, r0, r3; Add the third number to the subtotal ADD r0, r0, r4; Add the fourth number to the subtotal stop B ; stop SUBTRACTION of 4 numbers : Total = A-B-C-D Program: start MOV r0, r1; Make the first number the subtotal SUB r0, r0, r2; Add the second number to the subtotal SUB r0, r0, r3; Add the third number to the subtotal SUB r0, r0, r4; Add the fourth number to the subtotal stop B ; stop MULTIPLIATION of 4 numbers : Total = A X B X C X D Program: start MOV r0, r1; Make the first number the subtotal MUL r0, r0, r2; Add the second number to the subtotal MUL r0, r0, r3; Add the third number to the subtotal MUL r0, r0, r4; Add the fourth number to the subtotal stop B ; stop DIVISION of 4 numbers : Total = A/B/C/D Program: start MOV r0, r1; Make the first number the subtotal DIV r0, r0, r2; Add the second number to the subtotal DIV r0, r0, r3; Add the third number to the subtotal DIV r0, r0, r4; Add the fourth number to the subtotal stop B ; stop 3

4 Write an assembly language program to compute... 4x 2 + 3x,. if xis stored in r1. Store the result in r0 start MUL r0, r1, r1; result <--x * x LDR r2, =4; tmp <--4 MUL r0, r2, r0; result <--4 * x * x LDR r2, =3; tmp <--3 MUL r2, r1, r2; tmp <--x * tmp ADD r0, r0, r2; result <--result + tmp stop B stop II) Computing the greatest common divisor of two numbers using Euclid's GCD algorithm using branch instructions. MOV R0, #40 ; R0 is a MOV R1, #25 ; R1 is b again CMP R0, R1 SUBGT R0, R0, R1 SUBLT R1, R1, R0 BNE again halt B halt b)write a program to add numbers in an array using loop instruction addints MOV R4, #0 addloop LDR R2, [R0] ADD R4, R4, R2 ADD R0, R0, #4 SUBS R1, R1, #1 BNE addloop 4

5 2. Write an Assembly programs to configure and control General Purpose Input/Output (GPIO) port pins. /* Examples Program For "CP-JR ARM7 USB-LPC2148" */ /* Target MCU : Philips ARM7-LPC2148 */ /* : X-TAL : MHz */ /* : Run Speed MHz (With PLL) */ /* : PLL Setup = M(5),P(2) */ /* : VPB Clock = CPU Clock = MHz */ /* Keil Editor : uvision3 V3.03a */ /* Compiler : Keil CARM V2.50a */ /* Function : Example Used Fast GPIO Function */ /****************************************************/ // Connect P1.24 to LED For Test ON / OFF (Blink) #include "LPC214x.H" // LPC2148 MPU Register /* pototype section */ void delay(unsigned long int); Time Function // Delay int main(void) // Enable GPIO Function //SCS = 0x ; // Enable GPIO0 = Fast GPIO Mode SCS = 0x ; GPIO1 = Fast GPIO Mode // Enable // xxxx xxx1 xxxx xxxx xxxx xxxx xxxx xxxx 5

6 FIO1MASK = 0xFEFFFFFF; // Enable GPIO1[24] = Fast GPIO Mode FIO1DIR = 0x ; // Set GPIO-1[24] = Output FIO1SET = 0x ; // Set GPIO-1[24] Output Pin(OFF LED) // Loop Test Output GPIO1.24 while(1) // Loop Continue FIO1CLR = 0x ; // Clear Output GPIO1[24] Pin (ON LED) delay( ); // Display Delay FIO1SET = 0x ; (OFF LED) // Set Output GPIO1[24] Pin delay( ); // Display Delay /***********************/ /* Delay Time Function */ /* */ /***********************/ void delay(unsigned long int count1) while(count1 > 0) count1--; Decrease Counter // Loop 6

7 3. Write an Assembly programs to read digital values from external peripherals and execute them with the Target board. ( write a program to read digital values from eternal peripherals and execute them with the target board.) /* Examples Program For "CP-JR ARM7 USB-LPC2148" */ /* Target MCU : Philips ARM7-LPC2148 */ /* : X-TAL : MHz */ /* : Run Speed MHz (With PLL) */ /* : PLL Setup = M(5),P(2) */ /* : VPB Clock = CPU Clock = MHz */ /* Keil Editor : uvision3 V3.03a */ /* Compiler : Keil CARM V2.50a */ /* Function : Example Used DAC Generate Sinewave */ /****************************************************/ // P0.25 = DAC Output = Sinewave Signal #include "LPC214x.H" // LPC2148 MPU Register #include <stdio.h> // For Used Function printf int main(void) const static unsigned short table_sine[64] = Table(12Bit) // Sine Function 0x07FF, 0x08C8, 0x098E, 0x0A51, 0x0B0F, 0x0BC4, 0x0C71, 0x0D12, 0x0DA7, 0x0E2E, 0x0EA5, 0x0F0D, 0x0F63, 0x0FA6, 0x0FD7, 0x0FF5, 0x0FFF, 0x0FF5, 0x0FD7, 0x0FA6, 0x0F63, 0x0F0D, 0x0EA5, 0x0E2E, 0x0DA7, 0x0D12, 0x0C71, 0x0BC4, 7

8 0x0B0F, 0x0A51, 0x098E, 0x08C8, 0x07FF, 0x0736, 0x0670, 0x05AD, 0x04EF, 0x043A, 0x038D, 0x02EC, 0x0257, 0x01D0, 0x0159, 0x00F1, 0x009B, 0x0058, 0x0027, 0x0009, 0x0000, 0x0009, 0x0027, 0x0058, 0x009B, 0x00F1, 0x0159, 0x01D0, 0x0257, 0x02EC, 0x038D, 0x043A, 0x04EF, 0x05AD, 0x0670, 0x0736 ; int i = 0; // Pointer // Initial DAC (GPIO-0.25) By Set PINSEL1[19:18=10] // xxxx xxxx xxxx 10xx xxxx xxxx xxxx xxxx PINSEL1 &= 0xFFF3FFFF; DAC Pin Connect P0.25 // Select PINSEL1 = 0x ; while(1) // Loop Continue // 10-Bit Data = xxxx xxxx xxxx xxxx DDDD DDDD DDxx xxxx DACR = ((table_sine[i]/4) << 6); Output // Update DAC Sine //DACR = ((i * 16) << 6); // Update DAC SAW Output i++; // Next Pointer i &= 0x3F; // 8

9 5. Program to demonstrate Time delay program using built in Timer / Counter feature on IDE environment. (demonstrate Time delay program using built in timer/counter feature on IDE environment) Timer functionality: #include <LPC214X.H> main() // T0PR = 0x ; PINSEL0=0x ; T0CCR=0x ; T0TCR = 0x ; //T0MCR = 0x ; //T0MR1 = 0X f; while(1); Counter functionality: #include <LPC214X.H> void main() PINSEL0=0X ; T0TCR=0X01; T0CTCR=0X03; 9

10 7. Program to demonstrate setting up interrupt handlers. Press button to generate an interrupt and trace the program flow with debug terminal. /********************************************************************************* ******* * File Name : main.c * * Purpose : - This program describes the usage of GPIO pins * * to activate external interrupt pins * * Author : NTIL Engineers * * Date : Monday, November 01, 2004 * * Copyright or License : Monday, November 01, 2004 NTIL * * Algorithms : NONE * * Hardware notes : arm7tdmi controller * * Microcontroller : PHILIPS ARM 2104 * * Operating Speed : MHz * * Revision History : Version * * Table Of Contents : >>>main * * >>>int0isr * * >>>int1isr * * >>>int2isr * * >>>ledon * * >>>ledoff * * >>>ledinit * * >>>delay * *...HEADER FILES... * * >>>LPC210x.h * 10

11 * >>>irq.h * * Description : Building and Running * * * * To run from FLASH: * * make flash * * connect to Philips UTILITY * * Download the program * * To run from RAM: * * make ram * * connect to GDB * * Download the program * ********************************************************************************* ********/ #include "LPC210x.h" #include "irq.h" /* Interrupt Servce Routine for Ecternal Interrupt0 */ static void int0isr(void) attribute ((interrupt ("IRQ"))); /* Interrupt Servce Routine for Ecternal Interrupt1 */ static void int1isr(void) attribute ((interrupt ("IRQ"))); /* Interrupt Servce Routine for Ecternal Interrupt2 */ static void int2isr(void) attribute ((interrupt ("IRQ"))); /* To make LED's On */ static void ledon(unsigned long int led); /* To make LED's Off */ static void ledoff(unsigned long int led); /* Interrupt Servce Routine for Ecternal Interrupt0 */ static void int0isr(void); /* Interrupt Servce Routine for Ecternal Interrupt1 */ static void int1isr(void); /* Interrupt Servce Routine for Ecternal Interrupt2 */ static void int2isr(void); 11

12 /* Configuring P0.0-P0.7 for LED's */ static void ledinit(void); /* To create Delay */ static void delay(void); /********************************************************************************* ******* * Function name : Main * * Arguments : void * * Return Values : integer type * * Description : Program starts here * ********************************************************************************* *******/ int main(void) /* Configuring PINSEL0 register for Ext. Interrupts */ PINSEL0=0XA ; PINSEL1=0X ; /* Int0 is an IRQ interrupt */ VICIntSelect &= ~0x4000; /* Enable Int0 interrupt */ VICIntEnable = 0x4000; /* Use slot 0 for Int0 interrupt */ VICVectCntl0 = 0x2E; /* Set the address of ISR for slot 0 */ VICVectAddr0 = (unsigned int)int0isr; /* Int1 interrupt is an IRQ interrupt */ VICIntSelect &= ~0x8000; /* Enable Int1 interrupt */ VICIntEnable = 0x8000; /* Use slot 1 for Int1 interrupt */ 12

13 VICVectCntl1 = 0x2F; /* Set the address of ISR for slot 1 */ VICVectAddr1 = (unsigned int)int1isr; /* Int2 interrupt is an IRQ interrupt */ VICIntSelect &= ~0x10000; /* Enable Int2 interrupt */ VICIntEnable = 0x10000; /* Use slot 2 for Int2 interrupt */ VICVectCntl2 = 0x30; /* Set the address of ISR for slot 2 */ VICVectAddr2 = (unsigned int)int2isr; /* Function to Initialize LEDs */ ledinit(); /* Macro for Handling IRQ */ enable_irq(); while (1) /* End of MAIN Function */ /********************************************************************************* ******* * Function name : int0isr * * Arguments : void * * Return Values : void * * Description : Service Routine to Handle Int0 IRQ * ********************************************************************************* *******/ static void int0isr(void) ledon(0x ); delay(); 13

14 ledoff(0x ); /* Clear the Int0 interrupt */ EXTINT=0X01; /* Update VIC priorities */ VICVectAddr = 0; /* End of 'int0isr' function */ /********************************************************************************* ******* * Function name : int1isr * * Arguments : void * * Return Values : void * * Description : Service Routine to Handle Int1 IRQ * ********************************************************************************* *******/ static void int1isr(void) ledon(0x ); delay(); ledoff(0x ); /* Clear the Int1 interrupt */ EXTINT=0X02; /* Update VIC priorities */ VICVectAddr = 1; /* End of 'int1isr' function */ /********************************************************************************* ******* * Function name : int2isr * * Arguments : void * 14

15 * Return Values : void * * Description : Service Routine to Handle Int2 IRQ * ********************************************************************************* *******/ static void int2isr(void) ledon(0x ); delay(); ledoff(0x ); /* Clear the Int2 interrupt */ EXTINT=0X04; /* Update VIC priorities */ VICVectAddr = 2; /* End of 'int2isr' function */ /********************************************************************************* ******* * Function name : ledon * * Arguments : unsigned long int * * Return Values : void * * Description : To make LEDs On * ********************************************************************************* *******/ static void ledon(unsigned long int led) /* Makes LED ON */ IOCLR = led; /* End of 'ledon' function */ /********************************************************************************* ******* * Function name : ledoff * 15

16 * Arguments : unsigned long int * * Return Values : void * * Description : To Make LEDs Off * ********************************************************************************* *******/ static void ledoff(unsigned long int led) /* Makes LED Off */ IOSET = led; /* End of 'ledoff' function */ /********************************************************************************* ******* * Function name : ledinit * * Arguments : void * * Return Values : void * * Description : To Configure I/O lines for LEDs * ********************************************************************************* *******/ static void ledinit() /* Making P0.0-P0.7 as Output Lines */ IODIR = 0x000000FF; IOSET = 0x000000FF; /* End of 'ledinit' function */ /********************************************************************************* ******* * Function name : delay * * Arguments : void * * Return Values : void * 16

17 * Description : To create Delay * ********************************************************************************* *******/ static void delay(void) int i,j; for(i=0;i<500;i++) for(j=0;j<100;j++); /* End of 'delay' function */ /***********************End of File*************************************/ 17

18 8. Write a Program to Interface 8 Bit LED and Switch Interface. #include<lpc214x.h> ///////////////////////////// Delay Function ////////////////////////// void main_delay( unsigned int value ) unsigned int ui_temp1,ui_temp2; // Delay Variables for(ui_temp1=0;ui_temp1<value;ui_temp1++) for(ui_temp2=0;ui_temp2<5000;ui_temp2++); //Delay loop //Delay loop int main() IODIR0 = 0xffffffff; IODIR1 = 0xffffffff; while(1) IOSET0= 0xffffffff; IOSET1= 0xffffffff; main_delay(5000); IOCLR0= 0xffffffff; IOCLR1= 0xffffffff; main_delay(5000); 18

19 9. Program to implement Buzzer Interface on IDE environment #include<lpc214x.h> #define buzz 0x #define buzz_on IOCLR0=buzz #define buzz_off IOSET0=buzz void delay( unsigned int value ) unsigned int ui_temp1,ui_temp2; for(ui_temp1=0;ui_temp1<value;ui_temp1++) for(ui_temp2=0;ui_temp2<5000;ui_temp2++); int main() IODIR0 =buzz; while(1) buzz_on; delay(2000); buzz_off; delay(2000); 19

20 10. Program to Displaying a message in a 2 line x 16 Characters LCD display and verify the result in debug terminal. #include<lpc214x.h> // LPC2148 MPU Registers // Define LCD PinIO Mask #define LCD_RS 0x // P1.16( x ) #define LCD_EN 0x // P1.17( x ) #define LCD_D4 0x // P1.18( x ) #define LCD_D5 0x // P1.19( x ) #define LCD_D6 0x // P1.20( x ) #define LCD_D7 0x // P1.21( x ) ///////////////////////////// Delay Function ////////////////////////// void main_delay( unsigned int value ) unsigned int ui_temp1,ui_temp2; // Delay Variables for(ui_temp1=0;ui_temp1<value;ui_temp1++) //Delay loop for(ui_temp2=0;ui_temp2<5000;ui_temp2++); //Delay loop /////////////////////// LCD Command Sending Function///////////////////// void lcd_cmd(unsigned char val) unsigned int lcd_ch; // LCD Initial Data unsigned int lcd_i; // LCD Initial Delay Count IOCLR1 = LCD_RS ; // RS = 0 lcd_ch=((val>>4)&0x0f); // Strobe 4-Bit High-Nibble to LCD IOCLR1 = (LCD_D7 LCD_D6 LCD_D5 LCD_D4); // Reset 4-Bit Pin Data IOSET1 = (lcd_ch<<18); // Data Send to Respective Pins IOSET1 = LCD_EN ; // EN = 1 (Enable) for (lcd_i=0;lcd_i<10000;lcd_i++); //delay IOCLR1 = LCD_EN ; // EN = 0 (Disable) lcd_ch=(val&0x0f); // Strobe 4-Bit Low-Nibble to LCD IOCLR1 = (LCD_D7 LCD_D6 LCD_D5 LCD_D4); // Reset 4-Bit Pin Data IOSET1 = (lcd_ch<<18); // EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000 IOSET1 = LCD_EN ; // EN = 1 (Enable) for (lcd_i=0;lcd_i<10000;lcd_i++); //delay 20

21 IOCLR1 = LCD_EN ; // EN = 0 (Disable) for (lcd_i=0;lcd_i<10000;lcd_i++); //delay ///////////////////////LCD Single Charecter Display Function///////////////////////////////////////// void lcd_data(unsigned char val) unsigned int lcd_ch; // LCD Initial Data unsigned int lcd_i; // LCD Initial Delay Count IOSET1 = LCD_RS ; // RS = 1 lcd_ch=((val>>4)&0x0f); // Strobe 4-Bit High-Nibble to LCD IOCLR1 = (LCD_D7 LCD_D6 LCD_D5 LCD_D4); // Reset 4-Bit Pin Data IOSET1 = (lcd_ch<<18); // Data Send to Respective Pins IOSET1 = LCD_EN ; // EN = 1 (Enable) for (lcd_i=0;lcd_i<10000;lcd_i++); // delay IOCLR1 = LCD_EN ; // EN = 0 (Disable) lcd_ch=(val&0x0f); // Strobe 4-Bit Low-Nibble to LCD IOCLR1 = (LCD_D7 LCD_D6 LCD_D5 LCD_D4); // Reset 4-Bit Pin Data IOSET1 = (lcd_ch<<18); // Data Send to Respective Pins IOSET1 = LCD_EN ; for (lcd_i=0;lcd_i<10000;lcd_i++); //delay IOCLR1 = LCD_EN ; // EN = 1 (Enable) // EN = 0 (Disable) for (lcd_i=0;lcd_i<10000;lcd_i++); //delay ///////////////////// LCD String Display Function /////////////////// void lcd_puts(unsigned char* str) while(*str) // Cheack Data is there or not lcd_data(*str++); //LCD Single Charecter Display Function ///////////////// LCD Initialization Function //////////////////// void lcd_init() unsigned int lcd_main_i; // LCD Initial Delay Count PINSEL2 = 0x ; IODIR1 = 0x003F0000 ; // GPIO1[31..16] = I/O Function // GPIO1[21..16] = OUT Direction for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Power-On Delay (15 ms) IOCLR1 = ((LCD_D7 LCD_D6 LCD_D5 LCD_D4 LCD_RS LCD_EN)); // Reset (RS,EN,4-Bit Data) Pin IOSET1 = (LCD_D5 LCD_D4); // Set D4,D5 21

22 IOSET1 = LCD_EN ; for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); IOCLR1 = LCD_EN ; for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // EN = 1 (Enable) // Delay // EN = 0 (Disable) // Delay IOCLR1 = ((LCD_D7 LCD_D6 LCD_D5 LCD_D4 LCD_RS LCD_EN)); // Reset (RS,EN,4-Bit Data) Pin IOSET1 = (LCD_D5 LCD_D4); // Set D4,D5 IOSET1 = LCD_EN ; // EN = 1 (Enable) for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Delay IOCLR1 = LCD_EN ; // EN = 0 (Disable) for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // delay IOCLR1 = ((LCD_D7 LCD_D6 LCD_D5 LCD_D4 LCD_RS LCD_EN)); // Reset (RS,RW,EN,4-Bit Data) Pin IOSET1 = (LCD_D5 LCD_D4); // Set D4,D5 IOSET1 = LCD_EN ; // EN = 1 (Enable) for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Delay IOCLR1 = LCD_EN ; // EN = 0 (Disable) for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Delay IOCLR1 = ((LCD_D7 LCD_D6 LCD_D5 LCD_D4 LCD_RS LCD_EN)); // Reset (RS,RW,EN,4-Bit Data) Pin IOSET1 = (LCD_D5); // Set D4,D5 IOSET1 = LCD_EN ; // EN = 1 (Enable) for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Delay IOCLR1 = LCD_EN ; // EN = 0 (Disable) for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Delay lcd_cmd(0x28); // LCD 4-Bit Mode lcd_cmd(0x0c); // LCD Courser Blinking Stop lcd_cmd(0x06); // LCD Shift Display Right lcd_cmd(0x01); // LCD Clear Display for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Wait Command Ready ///////////////////////// MAIN Function //////////////////// int main() lcd_init(); // Initialization lcd_puts("lpc2148 LCD DEMO"); //Display Text lcd_cmd(0xc0); // Courser goto Secong Line lcd_puts(" Program "); //Display Text main_delay(5000); //delay lcd_cmd(0x01); // LCD Clear Display lcd_puts(" ELEGANT"); //Display Text lcd_cmd(0xc0); // Courser goto Secong Line lcd_puts(" Embedded Solu"); //Display Text while(1); // Continuous Loop 22

23 12. Program to demonstrate I2C Interface Serial EEPROM #include <LPC214x.H> /* LPC214x definitions */ #include "LCD.h" #include "i2c.h" unsigned char buf_size; unsigned char buf[70],bu[70],count; int main (void) unsigned char val,val1,val2,val3,val4,val5,val6,val7,val8,val9; lcd_init(); lcd_cmd(0x01); lcd_puts("eeprom WITH "); lcd_cmd(0xc0); lcd_puts(" LPC2148"); i2c_lpc_init(1); i2c_delay(10000); i2c_delay(10000); // Initialize I2C lcd_cmd(0x01); lcd_puts("data WRITING..."); eeprom_write(0,'9'); eeprom_write(1,'3'); eeprom_write(2,'9'); eeprom_write(3,'6'); eeprom_write(4,'6'); eeprom_write(5,'7'); eeprom_write(6,'1'); eeprom_write(7,'5'); eeprom_write(8,'4'); eeprom_write(9,'1'); i2c_delay(10000); i2c_delay(10000); //WRITING THE DAT TO EEPROM lcd_cmd(0x01); lcd_puts("data READING..."); i2c_delay(10000); i2c_delay(10000); val=eeprom_read(0); val1=eeprom_read(1); val2=eeprom_read(2); val3=eeprom_read(3); //READING DATA FROM EEPROM 23

24 val4=eeprom_read(4); val5=eeprom_read(5); val6=eeprom_read(6); val7=eeprom_read(7); val8=eeprom_read(8); val9=eeprom_read(9); lcd_cmd(0x01); lcd_data(val); lcd_data(val1); lcd_data(val2); lcd_data(val3); lcd_data(val4); lcd_data(val5); lcd_data(val6); lcd_data(val7); lcd_data(val8); lcd_data(val9); //DISPLAY THE DATA ON LCD 24

25 13. Demonstration of Serial communication. Transmission from Kit and reception from PC using Serial Port on IDE environment use debug terminal to trace the program. #include<lpc214x.h> // LPC2148 MPU Registers void uart0_init() // Uart0 Initialization Function PINSEL0 =0x ; // GPIO1[1,0] = Uart Function // Select P0.0 = TxD(UART0) // Select P0.1 = RxD(UART0) U0LCR =0X80; // Enable Programming of Divisor Latches U0DLL =97; // Program Divisor Latch(391) for 9600 Baud U0LCR =0X03; // Data Bit = 8 Bit void uart0_putch(unsigned char val) //Write character to UART0 while(!(u0lsr & 0x20)); // Wait TXD Buffer Empty U0THR =val; // Write Character unsigned char uart0_getch() //Read character from UART0 while(!(u0lsr & 0x01)); // Wait RXD Receive Data Ready return(u0rbr); // Get Receice Data & Return void uart0_puts( char *stringptr) while (*stringptr) uart0_putch(*stringptr++); ///////////////////////// MAIN Function //////////////////// int main() unsigned char i; //String Display Function // Cheack Data is there or not //Write character to UART0 //variable for recive data from uart buffer uart0_init(); // Uart0 Initialization Function uart0_putch(13); //next line command 13,10 uart0_putch(10); uart0_puts("elegant EMBEDDED SOLUTIONS"); //String Display on Hyperterminal uart0_putch(13); //next line command 13,10 uart0_putch(10); uart0_puts("***** UART0 DEMO PROGRAM *****"); //String Display on Hyperterminal uart0_putch(13); //next line command 13,10 uart0_putch(10); uart0_puts("***** Enter Some Test *****"); //String Display on Hyperterminal uart0_putch(13); //next line command 13,10 uart0_putch(10); while(1) // Continuous Loop i=uart0_getch(); //get data from uart uart0_putch(i); //print data on Hyperterminal 25

26 14. Generation of PWM Signal #include <lpc214x.h> //#define PLOCK 0x #define PWMPRESCALE 60 //60 PCLK cycles to increment TC by 1 i.e 1 Micro-second void initpwm(void); void main_delay( unsigned int value ) unsigned int ui_temp1,ui_temp2; for(ui_temp1=0;ui_temp1<value;ui_temp1++) for(ui_temp2=0;ui_temp2<5000;ui_temp2++); int main(void) initpwm(); //Initialize PWM //IO0DIR = 0x1; This is not needed! //Also by default all pins are configured as Inputs after MCU Reset. while(1) PWMMR1 = 1250; //T-ON=25%, Hence 25% Bright PWMLER = (1<<1); //Update Latch Enable bit for PWMMR1 main_delay(2000); PWMMR1 = 2500; //50% Bright PWMLER = (1<<1); main_delay(2000); PWMMR1 = 3750; //75% Bright PWMLER = (1<<1); main_delay(2000); PWMMR1 = 5000; //100% Bright PWMLER = (1<<1); main_delay(2000); void initpwm(void) /*Assuming that PLL0 has been setup with CCLK = 60Mhz and PCLK also = 60Mhz.*/ /*This is a per the Setup & Init Sequence given in the tutorial*/ PINSEL0 = (1<<1); // Select PWM1 output for Pin0.0 26

27 PWMPCR = 0x0; //Select Single Edge PWM - by default its single Edged so this line can be removed PWMPR = PWMPRESCALE-1; // 1 micro-second resolution PWMMR0 = 5000; // 10ms period duration PWMMR1 = 2500; // 2.5ms - pulse duration i.e width (Brigtness level) PWMMCR = (1<<1); // Reset PWMTC on PWMMR0 match PWMLER = (1<<1) (1<<0); // update MR0 and MR1 PWMPCR = (1<<9); // enable PWM output PWMTCR = (1<<1) ; //Reset PWM TC & PR //Now, the final moment - enable everything PWMTCR = (1<<0) (1<<3); // enable counters and PWM Mode //PWM Generation goes active now - LED must be 25% Bright after Reset!! //Now you can get the PWM output at Pin P0.0! /* #include<lpc214x.h> #define PLOCK 0x #define PWMPRESCALE 60 int main() PINSEL1 =0x ; //PWM channel 5 is selected */ 27

28 15. Program to demonstrate SD-MMC Card Interface. /* * RL-ARM - FlashFS * * Name: SD_FILE.C * Purpose: File manipulation example program * * This code is part of the RealView Run-Time Library. * Copyright (c) KEIL - An ARM Company. All rights reserved. * */ #include <RTL.h> /* RTL kernel functions & defines */ #include <stdio.h> /* standard I/O.h-file */ #include <ctype.h> /* character functions */ #include <string.h> /* string and memory functions */ #include "File_Config.h" #include "SD_File.h" /* Command Functions */ static void cmd_capture (char *par); static void cmd_type (char *par); static void cmd_rename (char *par); static void cmd_copy (char *par); static void cmd_delete (char *par); static void cmd_dir (char *par); static void cmd_format (char *par); static void cmd_help (char *par); static void cmd_fill (char *par); /* Local constants */ static const char intro[] = "\n\n\n\n\n\n\n\n" " \n" " SD/MMC Card File Manipulation example \n"; static const char help[] = "+ command function \n" " CAP \"fname\" [/A] captures serial data to a file \n" " [/A option appends data to a file] \n" " FILL \"fname\" [nnnn] create a file filled with text \n" " [nnnn - number of lines, default=1000] \n" " TYPE \"fname\" displays the content of a text file \n" " REN \"fname1\" \"fname2\" renames a file 'fname1' to 'fname2' \n" " COPY \"fin\" [\"fin2\"] \"fout\" copies a file 'fin' to 'fout' file \n" " ['fin2' option merges 'fin' and 'fin2'] \n" " DEL \"fname\" deletes a file \n" " DIR \"[mask]\" displays a list of files in the directory \n" " FORMAT [label [/FAT32]] formats Flash Memory Card \n" 28

29 " [/FAT32 option selects FAT32 file system] \n" " HELP or? displays this help \n" " \n"; static const SCMD cmd[] = "CAP", cmd_capture, "TYPE", cmd_type, "REN", cmd_rename, "COPY", cmd_copy, "DEL", cmd_delete, "DIR", cmd_dir, "FORMAT", cmd_format, "HELP", cmd_help, "FILL", cmd_fill, "?", cmd_help ; #define CMD_COUNT (sizeof (cmd) / sizeof (cmd[0])) /* Local variables */ static char in_line[160]; /* Local Function Prototypes */ static void dot_format (U64 val, char *sp); static char *get_entry (char *cp, char **pnext); static void init_card (void); /* * Process input string for long or short name entry * */ static char *get_entry (char *cp, char **pnext) char *sp, lfn = 0, sep_ch = ' '; if (cp == NULL) /* skip NULL pointers */ *pnext = cp; return (cp); for ( ; *cp == ' ' *cp == '\"'; cp++) /* skip blanks and starting " */ if (*cp == '\"') sep_ch = '\"'; lfn = 1; *cp = 0; for (sp = cp; *sp!= CR && *sp!= LF; sp++) if ( lfn && *sp == '\"') break; if (!lfn && *sp == ' ' ) break; for ( ; *sp == sep_ch *sp == CR *sp == LF; sp++) *sp = 0; if ( lfn && *sp == sep_ch) sp ++; break; 29

30 *pnext = (*sp)? sp : NULL; /* next entry */ return (cp); /* * Print size in dotted fomat * */ static void dot_format (U64 val, char *sp) if (val >= (U64)1e9) sp += sprintf (sp,"%d.",(u32)(val/(u64)1e9)); val %= (U64)1e9; sp += sprintf (sp,"%03d.",(u32)(val/(u64)1e6)); val %= (U64)1e6; sprintf (sp,"%03d.%03d",(u32)(val/1000),(u32)(val%1000)); return; if (val >= (U64)1e6) sp += sprintf (sp,"%d.",(u32)(val/(u64)1e6)); val %= (U64)1e6; sprintf (sp,"%03d.%03d",(u32)(val/1000),(u32)(val%1000)); return; if (val >= 1000) sprintf (sp,"%d.%03d",(u32)(val/1000),(u32)(val%1000)); return; sprintf (sp,"%d",(u32)(val)); /* * Capture serial data to file * */ static void cmd_capture (char *par) char *fname,*next; BOOL append,retv; FILE *f; fname = get_entry (par, &next); if (fname == NULL) printf ("\nfilename missing.\n"); return; append = FALSE; if (next) par = get_entry (next, &next); if ((strcmp (par, "/A") == 0) (strcmp (par, "/a") == 0)) append = TRUE; else 30

31 printf ("\ncommand error.\n"); return; printf ((append)? "\nappend data to file %s" : "\ncapture data to file %s", fname); printf("\npress ESC to stop.\n"); f = fopen (fname,append? "a" : "w"); /* open a file for writing */ if (f == NULL) printf ("\ncan not open file!\n"); /* error when trying to open file */ return; do retv = getline (in_line, sizeof (in_line)); fputs (in_line, f); while (retv == TRUE); fclose (f); /* close the output file */ printf ("\nfile closed.\n"); /* * Create a file and fill it with some text * */ static void cmd_fill (char *par) char *fname, *next; FILE *f; int i,cnt = 1000; fname = get_entry (par, &next); if (fname == NULL) printf ("\nfilename missing.\n"); return; if (next) par = get_entry (next, &next); if (sscanf (par,"%d", &cnt) == 0) printf ("\ncommand error.\n"); return; f = fopen (fname, "w"); /* open a file for writing */ if (f == NULL) printf ("\ncan not open file!\n"); /* error when trying to open file */ return; for (i = 0; i < cnt; i++) fprintf (f, "This is line # %d in file %s\n", i, fname); fclose (f); /* close the output file */ printf ("\nfile closed.\n"); 31

32 /* * Read file and dump it to serial window * */ static void cmd_type (char *par) char *fname,*next; FILE *f; int ch; fname = get_entry (par, &next); if (fname == NULL) printf ("\nfilename missing.\n"); return; printf("\nread data from file %s\n",fname); f = fopen (fname,"r"); /* open the file for reading */ if (f == NULL) printf ("\nfile not found!\n"); return; while ((ch = fgetc (f))!= EOF) /* read the characters from the file */ putchar (ch); /* and write them on the screen */ fclose (f); /* close the input file when done */ printf ("\nfile closed.\n"); /* * Rename a File * */ static void cmd_rename (char *par) char *fname,*fnew,*next,dir; fname = get_entry (par, &next); if (fname == NULL) printf ("\nfilename missing.\n"); return; fnew = get_entry (next, &next); if (fnew == NULL) printf ("\nnew Filename missing.\n"); return; if (strcmp (fname,fnew) == 0) printf ("\nnew name is the same.\n"); return; 32

33 dir = 0; if (*(fname + strlen(fname) - 1) == '\\') dir = 1; if (frename (fname, fnew) == 0) if (dir) printf ("\ndirectory %s renamed to %s\n",fname,fnew); else printf ("\nfile %s renamed to %s\n",fname,fnew); else if (dir) printf ("\ndirectory rename error.\n"); else printf ("\nfile rename error.\n"); /* * Copy a File * */ static void cmd_copy (char *par) char *fname,*fnew,*fmer,*next; FILE *fin,*fout; U32 cnt,total; char buf[512]; BOOL merge; fname = get_entry (par, &next); if (fname == NULL) printf ("\nfilename missing.\n"); return; fmer = get_entry (next, &next); if (fmer == NULL) printf ("\nnew Filename missing.\n"); return; fnew = get_entry (next, &next); if (fnew!= NULL) merge = TRUE; else merge = FALSE; fnew = fmer; 33

34 if ((strcmp (fname,fnew) == 0) (merge && strcmp (fmer,fnew) == 0)) printf ("\nnew name is the same.\n"); return; fin = fopen (fname,"r"); /* open the file for reading */ if (fin == NULL) printf ("\nfile %s not found!\n",fname); return; if (merge == FALSE) printf ("\ncopy file %s to %s\n",fname,fnew); else printf ("\ncopy file %s, %s to %s\n",fname,fmer,fnew); fout = fopen (fnew,"w"); /* open the file for writing */ if (fout == NULL) printf ("\nfailed to open %s for writing!\n",fnew); fclose (fin); return; total = 0; while ((cnt = fread (&buf, 1, 512, fin))!= 0) fwrite (&buf, 1, cnt, fout); total += cnt; fclose (fin); /* close input file when done */ if (merge == TRUE) fin = fopen (fmer,"r"); /* open the file for reading */ if (fin == NULL) printf ("\nfile %s not found!\n",fmer); else while ((cnt = fread (&buf, 1, 512, fin))!= 0) fwrite (&buf, 1, cnt, fout); total += cnt; fclose (fin); fclose (fout); dot_format (total, &buf[0]); printf ("\n%s bytes copied.\n", &buf[0]); /*

35 * Delete a File * */ static void cmd_delete (char *par) char *fname,*next,dir; fname = get_entry (par, &next); if (fname == NULL) printf ("\nfilename missing.\n"); return; dir = 0; if (*(fname + strlen(fname) - 1) == '\\') dir = 1; if (fdelete (fname) == 0) if (dir) printf ("\ndirectory %s deleted.\n",fname); else printf ("\nfile %s deleted.\n",fname); else if (dir) printf ("\ndirectory %s not found or not empty.\n",fname); else printf ("\nfile %s not found.\n",fname); /* * Print a Flash Memory Card Directory * */ static void cmd_dir (char *par) U64 fsize; U32 files,dirs,i; char temp[32],*mask,*next,ch; FINFO info; mask = get_entry (par, &next); if (mask == NULL) mask = "*.*"; printf ("\nfile System Directory..."); files = 0; dirs = 0; 35

36 fsize = 0; info.fileid = 0; while (ffind (mask,&info) == 0) if (info.attrib & ATTR_DIRECTORY) i = 0; while (strlen((const char *)info.name+i) > 41) ch = info.name[i+41]; info.name[i+41] = 0; printf ("\n%-41s", &info.name[i]); info.name[i+41] = ch; i += 41; printf ("\n%-41s <DIR> ", &info.name[i]); printf (" %02d.%02d.%04d %02d:%02d", info.time.day, info.time.mon, info.time.year, info.time.hr, info.time.min); dirs++; else dot_format (info.size, &temp[0]); i = 0; while (strlen((const char *)info.name+i) > 41) ch = info.name[i+41]; info.name[i+41] = 0; printf ("\n%-41s", &info.name[i]); info.name[i+41] = ch; i += 41; printf ("\n%-41s %14s ", &info.name[i], temp); printf (" %02d.%02d.%04d %02d:%02d", info.time.day, info.time.mon, info.time.year, info.time.hr, info.time.min); fsize += info.size; files++; if (info.fileid == 0) printf ("\nno files..."); else dot_format (fsize, &temp[0]); printf ("\n %9d File(s) %21s bytes", files, temp); dot_format (ffree(""), &temp[0]); if (dirs) printf ("\n %9d Dir(s) %21s bytes free.\n", dirs, temp); else printf ("\n%56s bytes free.\n",temp); 36

37 /* * Format a Flash Memory Card * */ static void cmd_format (char *par) char *label,*next,*opt; char arg[20]; U32 retv; label = get_entry (par, &next); if (label == NULL) label = "KEIL"; strcpy (arg, label); opt = get_entry (next, &next); if (opt!= NULL) if ((strcmp (opt, "/FAT32") == 0) (strcmp (opt, "/fat32") == 0)) strcat (arg, "/FAT32"); printf ("\nformat Flash Memory Card? [Y/N]\n"); retv = getkey(); if (retv == 'y' retv == 'Y') /* Format the Card with Label "KEIL". "*/ if (fformat (arg) == 0) printf ("Memory Card Formatted.\n"); printf ("Card Label is %s\n",label); else printf ("Formatting failed.\n"); /* * Display Command Syntax help * */ static void cmd_help (char *par) printf (help); /* * Initialize a Flash Memory Card * */ static void init_card (void) U32 retv; while ((retv = finit (NULL))!= 0) /* Wait until the Card is ready*/ if (retv == 1) printf ("\nsd/mmc Init Failed"); printf ("\ninsert Memory card and press key...\n"); getkey (); 37

38 else printf ("\nsd/mmc Card is Unformatted"); strcpy (&in_line[0], "KEIL\r\n"); cmd_format (&in_line[0]); /* * Main: * */ int main (void) char *sp,*cp,*next; U32 i; init_comm (); /* init communication interface*/ printf (intro); /* display example info */ printf (help); init_card (); while (1) printf ("\ncmd> "); /* display prompt */ fflush (stdout); /* get command line input */ if (getline (in_line, sizeof (in_line)) == FALSE) continue; sp = get_entry (&in_line[0], &next); if (*sp == 0) continue; for (cp = sp; *cp && *cp!= ' '; cp++) *cp = toupper (*cp); /* command to upper-case */ for (i = 0; i < CMD_COUNT; i++) if (strcmp (sp, (const char *)&cmd[i].val)) continue; init_card(); /* check if card is removed */ cmd[i].func (next); /* execute command function */ break; if (i == CMD_COUNT) printf ("\ncommand error\n"); /* * end of file * */ 38

39 PART- II: Write the following programs to understand the use of RTOS with ARM Processor on IDE Environment using ARM Tool chain and Library: 1. Create an application that creates two tasks that wait on a timer whilst the main task loops. // Hedar File #include <RTL.h> int count=10000; int count1=10000; // Task ID's OS_TID id1, id2; // Task Declarations task void ORL_task1 (void); task void ORL_task2 (void); // Task1 Definition task void ORL_task1 (void) // Step - 1: Generate Task ID for Task1 id1 = os_tsk_self (); // Step - 2: Assign Task ID for Task2 id2 = os_tsk_create (ORL_task2, 1); while(1) while(count) count--; // Indicate to task2 completion of do-this os_evt_set (0x0004, id2); // Wait for completion of do-that (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); // Wait for 50ms os_dly_wait (5); // Task2 Definition task void ORL_task2 (void) while(1) 39

40 while(count1) count1--; // Wait for completion of do-this (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); //Wait for 20ms os_dly_wait (2); // Task1 Completion os_evt_set (0x0004, id1); // Main Function int main (void) os_sys_init (ORL_task1); 40

41 2. Write an application that creates a task which is scheduled when a button is pressed, which illustrates the use of an event set between an ISR and a task. // RT LINUX HEDAR FILE #include <RTL.H> #include <LPC21XX.H> int count=10000; #define led 0x // Task ID's OS_TID id1; // Task Declaration task void ORL_task1(void); // Task Definition task void ORL_task1(void) // Step - 1: Generate Task ID id1=os_tsk_self(); while(1) while(count) count--; IOCLR0=led; // Wait for completion of do-that (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); // Wait for 50ms os_dly_wait (5); count=10000; // ISR void INT2(void) irq IOSET0=led; EXTINT = 1; VICVectAddr= 0x ; // Interrupt Declaration void inter(void) EXTMODE = 1; EXTPOLAR = 0; //Edge sensitive mode on EINT0 //Falling Edge Sensitive 41

42 PINSEL0 = 0x C; //Enable EINT2 on P0.1 VICVectCntl0 = 0x20 14; //15 is index of EINT0 VICVectAddr0 = (unsigned long) INT2; VICIntEnable = 1<<14; //Enable EINT0 // Main Function int main() IODIR0=led; // Output inter(); // Interrupt Enable os_sys_init(orl_task1); 42

43 3. Write an application that Demonstrates the interruptible ISRs(Requires timer to have higher priority than external interrupt button) // RT LINUX HEDAR FILE #include <RTL.H> #include <LPC21XX.H> int count=10000; #define led 0x // Task ID's OS_TID id1; // Task Declaration task void ORL_task1(void); // Task Definition task void ORL_task1(void) // Step - 1: Generate Task ID id1=os_tsk_self(); while(1) while(count) count--; IOCLR0=led; // Wait for completion of do-that (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); // Wait for 50ms os_dly_wait (5); count=10000; // ISR void INT2(void) irq IOSET0=led; EXTINT = 1; VICVectAddr= 0x ; void T0isr (void) irq 43

44 T0EMR = 0x ; //Set MAT1 high for begining of the cycle T0MR1++; //Increment PWM Duty cycle T0MR1 = T0MR1&0x000000FF; //Limit duty cycle T0IR = 0x ; //Clear match 0 interrupt VICVectAddr = 0x ; //Dummy write to signal end of interrupt // Interrupt Declaration void inter(void) EXTMODE = 1; //Edge sensitive mode on EINT2 EXTPOLAR = 0; //Falling Edge Sensitive PINSEL0 = 0x C; //Enable EINT2 on P0.14 VICVectCntl0 = 0x20 14; //15 is index of EINT2 VICVectAddr0 = (unsigned long) INT2; VICIntEnable = 1<<14; //Enable EINT2 // Main Function int main() VPBDIV = 0x ; // Configure the VPB divi PINSEL0 = 0x ; //Match1 as output T0PR = 0x E; //Load prescaler T0TCR = 0x ; //Reset counter and prescaler T0MCR = 0x ; //On match reset the counter and generate an interrupt T0MR0 = 0x ; //Set the cycle time T0MR1 = 0x ; // Set duty cycle to zero T0EMR = 0x ; //On match clear MAT1 T0TCR = 0x ; //enable timer VICVectAddr4 = (unsigned)t0isr; VICVectCntl4 = 0x ; VICIntEnable = 0x ; //Set the timer ISR vector address //Set channel //Enable the interrupt IODIR0=led; // Output inter(); // Interrupt Enable os_sys_init(orl_task1); 44

45 5. Write an application that creates two tasks of the same priority and sets the time slice period to illustrate time slicing. // Hedar Files #include <RTL.H> #include "MAD/ORL.H" #include "MAD/DELAY.H" // Variables U32 count1,count2; // Task ID's OS_TID id1,id2; // Task Declarations task void ORL_task1(void); task void ORL_task2(void); //Task1 Definition task void ORL_task1(void) id1=os_tsk_self(); os_tsk_prio_self(2); id2=os_tsk_create(orl_task2,2); while(1) count1++; os_dly_wait(2); os_evt_set(0x0004,id2); // Task2 Definition task void ORL_task2(void) while(1) count2++; os_dly_wait(2); os_evt_set(0x0004,id1); // Main Function int main() os_sys_init(orl_task1); 45

46 Interfacing Programs: 6. Write an application that creates a two task to Blinking two different LEDs at different Timings. /* Target: Blinking LED's at different Timings Programmer: Madhu ORANGE RESEARCH LABS */ // Hedar Files #include <RTL.H> #include "MAD/ORL.H" // LED's #define led1 0x #define led2 0x // Task ID's OS_TID id1,id2; void delay () unsigned int y,h; for (y=0;y<40000;y++) for (h=0;h<200;h++); // Task Declarations task void ORL_task1(void); task void ORL_task2(void); // Task1 Definition task void ORL_task1 (void) // Step - 1: Generate Task ID for Task1 id1 = os_tsk_self (); // Step - 2: Assign Task ID for Task2 id2 = os_tsk_create (ORL_task2, 1); while(1) IOSET0=led1; os_dly_wait(10); IOCLR0=led1; // os_dly_wait(1); 46

47 // Indicate to task2 completion of do-this os_evt_set (0x0004, id2); // Wait for completion of do-that (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); os_dly_wait(5); // Task2 Definition task void ORL_task2 (void) while(1) IOSET0=led2; os_dly_wait(100); IOCLR0=led2; // os_dly_wait(1); // Wait for completion of do-this (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); //Wait for 20ms os_dly_wait (2); // Task1 Completion os_evt_set (0x0004, id1); // Main Function int main() IODIR0 =led1 led2; os_sys_init(orl_task1); 47

48 7. Write an application that creates a two task displaying two different messages in LCD display in two lines. /* Target: Displaying Message through LCD Programmer: Madhu ORANGE RESEARCH LABS */ // Hedar Files #include <RTL.H> #include "MAD/ORL.H" #include "MAD/DELAY.H" #include "MAD/LCD.H" // TASK IDS OS_TID id1,id2; // TASK DECLARATIONS task void ORL_task1(void); task void ORL_task2(void); // Task1 Definition task void ORL_task1 (void) // Step - 1: Generate Task ID for Task1 id1 = os_tsk_self (); // Step - 2: Assign Task ID for Task2 id2 = os_tsk_create (ORL_task2, 1); while(1) lcd_cmd(0x80); lcd_string("ees"); // Indicate to task2 completion of do-this /// os_evt_set (0x0004, id2); // Wait for completion of do-that (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); os_dly_wait(20); os_evt_set (0x0004, id1); // Task2 Definition task void ORL_task2 (void) 48

49 while(1) lcd_cmd(0xc0); lcd_string("embedded "); // Wait for completion of do-this (0xffff means no time-out) os_evt_wait_or (0x0004, 0xffff); //Wait for 20ms os_dly_wait (20); // Task1 Completion os_evt_set (0x0004, id1); // Main Function int main() lcd_init(); os_sys_init(orl_task1); 49

50 8. Sending messages to mailbox by one task and reading the message from mailbox by another task. /* Target: Sending and Receiving Tasks for Mail Box */ #include <RTL.h> #include "MAD/ORL.H" #include "MAD/DELAY.H" #include "MAD/UART.H" #include <stdio.h> // Task ID's OS_TID id1; OS_TID id2; typedef struct float voltage; float current; U32 counter; T_MEAS; os_mbx_declare (MsgBox,16); /* Declare an RTX mailbox */ _declare_box (mpool,sizeof(t_meas),16);/* Dynamic memory pool */ // Task Declarations task void send_task (void); task void rec_task (void); // Task1 Definition task void send_task (void) T_MEAS *mptr; id1 = os_tsk_self (); id2 = os_tsk_create (rec_task, 0); os_mbx_init (MsgBox, sizeof(msgbox));/* initialize the mailbox */ os_dly_wait (5); mptr = _alloc_box (mpool); /* Allocate a memory for the message */ mptr->voltage = ; /* Set the message content */ mptr->current = 17.54; mptr->counter = ; os_mbx_send (MsgBox, mptr, 0xffff); /* Send the message to the mailbox */ IOSET1 = 0x10000; os_dly_wait (100); 50

51 mptr = _alloc_box (mpool); mptr->voltage = ; /* Prepare a 2nd message */ mptr->current = 12.41; mptr->counter = ; os_mbx_send (MsgBox, mptr, 0xffff); /* And send it. */ os_tsk_pass (); /* Cooperative multitasking */ IOSET1 = 0x20000; os_dly_wait (100); mptr = _alloc_box (mpool); mptr->voltage = ; /* Prepare a 3rd message */ mptr->current = 11.89; mptr->counter = ; os_mbx_send (MsgBox, mptr, 0xffff); /* And send it. */ IOSET1 = 0x40000; os_dly_wait (100); os_tsk_delete_self (); /* We are done here, delete this task */ // Task2 Definition task void rec_task (void) T_MEAS *rptr; while(1) os_mbx_wait (MsgBox, (void **)&rptr, 0xffff); /* wait for the message */ printf ("\nvoltage: %.2f V\n",rptr->voltage); printf ("Current: %.2f A\n",rptr->current); printf ("Number of cycles: %d\n",rptr->counter); _free_box (mpool, rptr); /* free memory allocated for message */ // Main Function int main (void) IODIR1 = 0xFF0000; uart0_init(); _init_box (mpool, sizeof(mpool), /* initialize the 'mpool' memory for */ sizeof(t_meas)); /* the membox dynamic allocation */ os_sys_init (send_task); /* initialize and start task 1 */ 51

52 9. Sending message to PC through serial port by three different tasks on priority Basis. /* Target: Sending Messages to PC on Priority Basis */ // Hedar Files #include <RTL.H> #include "MAD/ORL.H" #include "MAD/DELAY.H" #include "MAD/UART.H" // Task ID's OS_TID id1,id2,id3; // Task Declarations task void ORL_task1(void); task void ORL_task2(void); task void ORL_task3(void); // Task1 Definition task void ORL_task1(void) os_tsk_prio_self(2); id1=os_tsk_self(); id2=os_tsk_create(orl_task2,1); id3=os_tsk_create(orl_task3,2); while(1) uart0_string("welcome"); os_dly_wait(5); // Task2 Definition task void ORL_task2(void) while(1) uart0_string("embedded SYS LAB"); os_dly_wait(5); // Task3 Definition task void ORL_task3(void) while(1) 52

LABORATORY MANUAL EMBEDDED SYSTEMS LABORATORY. M. Tech I Year I Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

LABORATORY MANUAL EMBEDDED SYSTEMS LABORATORY. M. Tech I Year I Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG. LABORATORY MANUAL EMBEDDED SYSTEMS LABORATORY M. Tech I Year I Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG. BALAJI INSTITUTE OF TECHNOLOGY & SCIENCE Laknepally, Narsampet, Warangal 506331 LIST

More information

ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25

ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25 Objective ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25 This tutorial is to introduce the Keil µvision4 IDE and Keil RL-RTX. Students will experiment with inter-process communication

More information

ENGN3213. Digital Systems & Microprocessors. HLAB 6: ARM Embedded Systems I

ENGN3213. Digital Systems & Microprocessors. HLAB 6: ARM Embedded Systems I Department of Engineering Australian National University ENGN3213 Digital Systems & Microprocessors HLAB 6: ARM Embedded Systems I V3.0 Copyright 2010 G.G. Borg ANU Engineering 1 Contents 1 HLAB 6: ARM

More information

AN Full-duplex software UART for LPC2000. Document information

AN Full-duplex software UART for LPC2000. Document information Full-duplex software UART for LPC2000 Rev. 01 17 January 2008 Application note Document information Info Keywords Abstract Content LPC2000, UART, software This application note illustrates how a simple

More information

An Example of using Keil uvision3 for creating Keil ARM s Project File

An Example of using Keil uvision3 for creating Keil ARM s Project File An Example of using Keil uvision3 for creating Keil ARM s Project File In this chapter, represent how to write C Language Program via Keil ARM for translating orders under Text Editor Program of Keil (Keil

More information

Lab Experiment 9: LCD Display

Lab Experiment 9: LCD Display Lab Experiment 9: LCD Display 1 Introduction Liquid Crystal Displays (LCDs) provide an effective way for processors to communicate with the outside world. The LPC2148 board used in the lab is equipped

More information

ARM HOW-TO GUIDE Interfacing Switch with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Switch with LPC2148 ARM ARM HOW-TO GUIDE Interfacing Switch with LPC48 ARM Contents at a Glance ARM7 LPC48 Primer Board... 3 Switch... 3 Interfacing Switch... 4 Interfacing Switch with LPC48... 5 Pin Assignment with LPC48...

More information

AN Entering ISP mode from user code. Document information. ARM ISP, bootloader

AN Entering ISP mode from user code. Document information. ARM ISP, bootloader Rev. 03 13 September 2006 Application note Document information Info Keywords Abstract Content ARM ISP, bootloader Entering ISP mode is normally done by sampling a pin during reset. This application note

More information

ARM HOW-TO GUIDE Interfacing Buzzer with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Buzzer with LPC2148 ARM ARM HOW-TO GUIDE Interfacing Buzzer with LPC2148 ARM Contents at a Glance ARM7 LPC2148 Primer Board... 3 Buzzer... 3 Interfacing Buzzer... 4 Interfacing Buzzer with LPC2148... 5 Pin Assignment with LPC2148...

More information

Experiment 3. Interrupts. Hazem Selmi, Ahmad Khayyat

Experiment 3. Interrupts. Hazem Selmi, Ahmad Khayyat Experiment 3 Interrupts Hazem Selmi, Ahmad Khayyat Version 162, 24 February 2017 Table of Contents 1. Objectives........................................................................................

More information

Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil cvision3 Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil uvision3

Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil cvision3 Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil uvision3 Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil uvision3 Generally, GCCARM program is C-Complier Program only but Text Editor Program is not included. So, if you want to develop ARM7 Program

More information

Embedded Systems. School of Computer Science

Embedded Systems. School of Computer Science Embedded Systems Sivan Toledo School of Computer Science Tel-Aviv University Students Expectations Before I start talking, what do you hope to learn? What is An Embedded System? What is An Embedded System?

More information

ARM HOW-TO GUIDE Interfacing I2C-7SEG with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing I2C-7SEG with LPC2148 ARM ARM HOW-TO GUIDE Interfacing I2C-7SEG with LPC2148 ARM Contents at a Glance ARM7 LPC2148 Primer Board... 3 I2C (Inter Integrated Circuit)... 3 Seven Segment Display... 4 Interfacing I2C - Seven Segment

More information

AN10254 Philips ARM LPC microcontroller family

AN10254 Philips ARM LPC microcontroller family Rev. 02 25 October 2004 Application note Document information Info Content Keywords ARM LPC, Timer 1 Abstract Simple interrupt handling using Timer 1 peripheral on the ARM LPC device is shown in this application

More information

I2C on the HMC6352 Compass

I2C on the HMC6352 Compass I 2 C Bus The I 2 C bus is a two-wire bus(plus ground) where the two wire are called SCL Clock line SDA Data line Gnd Ground line This is a synchronous bus. SCL is the synchronizing signal. SCL and SDA

More information

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca. LCD Modules A common output display device used with low cost embedded systems is a character LCD display. The displays are available as complete modules with a standard microprocessor parallel interface.

More information

ARM HOW-TO GUIDE Interfacing GPS with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing GPS with LPC2148 ARM ARM HOW-TO GUIDE Interfacing GPS with LPC2148 ARM Contents at a Glance ARM7 LPC2148 Primer Board... 3 GPS (Global Positioning Systems)... 3 Interfacing GPS... 4 Interfacing GPS with LPC2148... 5 Pin Assignment

More information

ARM HOW-TO GUIDE Interfacing Stepper Motor with LPC2148

ARM HOW-TO GUIDE Interfacing Stepper Motor with LPC2148 ARM HOW-TO GUIDE Interfacing Stepper Motor with LPC2148 Contents at a Glance ARM7 LPC2148 Slicker Board... 3 Stepper Motor... 3 Interfacing Stepper Motor... 4 Interfacing Stepper Motor with LPC2148...

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang ECE254 Lab3 Tutorial Introduction to MCB1700 Hardware Programming Irene Huang Lab3 Requirements : API Dynamic Memory Management: void * os_mem_alloc (int size, unsigned char flag) Flag takes two values:

More information

// and verify that there is a sine wave with frequency <FREQUENCY> and

// and verify that there is a sine wave with frequency <FREQUENCY> and F330DC_IDA0_SineWave.c Copyright 2006 Silicon Laboratories, Inc. http:www.silabs.com Program Description: This program outputs a sine wave using IDA0. IDA0's output is scheduled to update at a rate determined

More information

CMPE3D02/SMD02 Embedded Systems

CMPE3D02/SMD02 Embedded Systems School of Computing Sciences CMPE3D02/SMD02 Embedded Systems Laboratory Sheet 5: 1.0 Introduction MDK-ARM: Introduction to RL-RTX RL-RTX is the real-time operating system (RTOS) component of the ARM Real-

More information

Embedded System Curriculum

Embedded System Curriculum Embedded System Curriculum ADVANCED C PROGRAMMING AND DATA STRUCTURE (Duration: 25 hrs) Introduction to 'C' Objectives of C, Applications of C, Relational and logical operators, Bit wise operators, The

More information

Lab 3a: Scheduling Tasks with uvision and RTX

Lab 3a: Scheduling Tasks with uvision and RTX COE718: Embedded Systems Design Lab 3a: Scheduling Tasks with uvision and RTX 1. Objectives The purpose of this lab is to lab is to introduce students to uvision and ARM Cortex-M3's various RTX based Real-Time

More information

LAB1. Get familiar with Tools and Environment

LAB1. Get familiar with Tools and Environment LAB1 Get familiar with Tools and Environment Outline Intro to ARMmite Pro development board Intro to LPC2103 microcontroller Cross development environment and tools Program the broad in C: light the LED

More information

Serial Compact Flash Serial CF Card Module User Manual

Serial Compact Flash Serial CF Card Module User Manual CUBLOC Peripheral Serial Compact Flash Serial Card Module User Manual 3. Specifications Model -COM5 -COM3 Voltage 4.5~5.5V 2.7~5.5V - 115200 bps: 20KB/s - 115200 bps: 15KB/s Read Speed - 9600 bps: 6KB/s

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

C programming basics T3-1 -

C programming basics T3-1 - C programming basics T3-1 - Outline 1. Introduction 2. Basic concepts 3. Functions 4. Data types 5. Control structures 6. Arrays and pointers 7. File management T3-2 - 3.1: Introduction T3-3 - Review of

More information

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

Chapter 4. Enhancing ARM7 architecture by embedding RTOS Chapter 4 Enhancing ARM7 architecture by embedding RTOS 4.1 ARM7 architecture 4.2 ARM7TDMI processor core 4.3 Embedding RTOS on ARM7TDMI architecture 4.4 Block diagram of the Design 4.5 Hardware Design

More information

ARM HOW-TO GUIDE Interfacing Keypad with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Keypad with LPC2148 ARM ARM HOW-TO GUIDE Interfacing Keypad with LPC2148 ARM Contents at a Glance ARM7 LPC2148 Primer Board... 3 Keypad... 3 Interfacing keypad... 4 Interfacing keypad with LPC2148... 6 Pin Assignment with LPC2148...

More information

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang ECE254 Lab3 Tutorial Introduction to Keil LPC1768 Hardware and Programmers Model Irene Huang Lab3 Part A Requirements (1) A function to obtain the task information OS_RESULT os_tsk_get(os_tid task_id,

More information

Experiment 1. Development Platform. Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh

Experiment 1. Development Platform. Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh Experiment 1 Development Platform Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh Version 162, 13 February 2017 Table of Contents 1. Objectives........................................................................................

More information

#include <stdio.h> // // Global CONSTANTS

#include <stdio.h> // // Global CONSTANTS Distance.c Author: Baylor Electromechanical Systems Operates on an external 18.432 MHz oscillator. Target: Cygnal Educational Development Board / C8051F020 Tool chain: KEIL C51 6.03 / KEIL EVAL C51 Utilizes

More information

ECE551 Midterm Version 1

ECE551 Midterm Version 1 Name: ECE551 Midterm Version 1 NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual

More information

Generating PWM on LPCXpresso - LPC1769

Generating PWM on LPCXpresso - LPC1769 2012 Generating PWM on LPCXpresso - LPC1769 Author: Manoj PWM Pulse Width Modulation, or PWM, is a well known technique used in power controlling delivering the preferred amount of power to the load. It

More information

AN Philips LPC2000 CAN driver. Document information

AN Philips LPC2000 CAN driver. Document information Rev. 01 02 March 2006 Application note Document information Info Keywords Abstract Content CAN BUS, MCU, LPC2000, ARM7, SJA1000 This application note describes the CAN controller hardware application programming

More information

EMBEDDED SYSTEMS LABORATORY

EMBEDDED SYSTEMS LABORATORY EMBEDDED SYSTEMS LABORATORY LAB MANUAL Year : 2017-2018 Course Code : BES102 Regulations : IARE - R16 Semester : II Branch : ECE Class : M.TECH I Yr. II Sem Prepared by Mr. N Papa Rao Asst. Professor,

More information

Embedded assembly is more useful. Embedded assembly places an assembly function inside a C program and can be used with the ARM Cortex M0 processor.

Embedded assembly is more useful. Embedded assembly places an assembly function inside a C program and can be used with the ARM Cortex M0 processor. EE 354 Fall 2015 ARM Lecture 4 Assembly Language, Floating Point, PWM The ARM Cortex M0 processor supports only the thumb2 assembly language instruction set. This instruction set consists of fifty 16-bit

More information

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE Fujitsu Microelectronics (Shanghai) Co., Ltd. Application Note MCU-AN-500009-E-10 F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB95200H/210H SERIES HOW TO USE DBG PIN APPLICATION NOTE Revision History Revision

More information

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite. EMBEDDED ARM TRAINING SUITE ARM SUITE INCLUDES ARM 7 TRAINER KIT COMPILER AND DEBUGGER THROUGH JTAG INTERFACE PROJECT DEVELOPMENT SOLUTION FOR ARM 7 e-linux LAB FOR ARM 9 TRAINING PROGRAM INTRODUCTION

More information

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529 Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529 Contents at a Glance PS PRIMER MSP430 kit... 3 Keypad... 4 Interfacing keypad... 4 Interfacing keypad with MSP430F5529...

More information

Speed Control of a DC Motor using Digital Control

Speed Control of a DC Motor using Digital Control Speed Control of a DC Motor using Digital Control The scope of this project is threefold. The first part of the project is to control an LCD display and use it as part of a digital tachometer. Secondly,

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE Fujitsu Microelectronics (Shanghai) Co., Ltd Application Note MCU-AN-500009-E-10 F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB95200H/210H SERIES HOW TO USE DBG PIN APPLICATION NOTE Revision History Revision

More information

Lab5 2-Nov-18, due 16-Nov-18 (2 weeks duration) Lab6 16-Nov-19, due 30-Nov-18 (2 weeks duration)

Lab5 2-Nov-18, due 16-Nov-18 (2 weeks duration) Lab6 16-Nov-19, due 30-Nov-18 (2 weeks duration) CS1021 AFTER READING WEEK Mid-Semester Test NOW Thurs 8th Nov @ 9am in Goldsmith Hall (ALL students to attend at 9am) Final 2 Labs Lab5 2-Nov-18, due 16-Nov-18 (2 weeks duration) Lab6 16-Nov-19, due 30-Nov-18

More information

80C51 Block Diagram. CSE Overview 1

80C51 Block Diagram. CSE Overview 1 80C51 Block Diagram CSE 477 8051 Overview 1 80C51 Memory CSE 477 8051 Overview 3 8051 Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits i.e. addresses for only 256 bytes! PC is

More information

C Language Programming

C Language Programming C Language Programming for the 8051 Overview C for microcontrollers Review of C basics Compilation flow for SiLabs IDE C extensions In-line assembly Interfacing with C Examples Arrays and Pointers I/O

More information

UM LPC2101/02/03 User manual. Document information

UM LPC2101/02/03 User manual. Document information LPC2101/02/03 User manual Rev. 4 13 May 2009 User manual Document information Info Keywords Abstract Content LPC2101, LPC2102, LPC2103, ARM, ARM7, embedded, 32-bit, microcontroller LPC2101/02/03 User manual

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Highlights. FP51 (FPGA based 1T 8051 core)

Highlights. FP51 (FPGA based 1T 8051 core) Copyright 2017 PulseRain Technology, LLC. FP51 (FPGA based 1T 8051 core) 10555 Scripps Trl, San Diego, CA 92131 858-877-3485 858-408-9550 http://www.pulserain.com Highlights 1T 8051 Core Intel MCS-51 Compatible

More information

C:\CYGNAL\Examples\C8051F02x\C\Edu_Board_Source_Code\Magcard.c

C:\CYGNAL\Examples\C8051F02x\C\Edu_Board_Source_Code\Magcard.c Magcard.c Author: Baylor Electromechanical Systems Operates on an external 18.432 MHz oscillator. Target: Cygnal Educational Development Board / C8051F020 Tool chain: KEIL C51 6.03 / KEIL EVAL C51 This

More information

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly. More on Programming the 9S12 in C Huang Sections 5.2 through 5.4 Introduction to the MC9S12 Hardware Subsystems Huang Sections 8.2-8.6 ECT_16B8C Block User Guide A summary of MC9S12 hardware subsystems

More information

Timer 32. Last updated 8/7/18

Timer 32. Last updated 8/7/18 Last updated 8/7/18 Basic Timer Function Delay Counter Load a value into a counter register The counter counts Down to zero (count down timer) Up from zero (count up timer) An action is triggered when

More information

Introduction to the MC9S12 Hardware Subsystems

Introduction to the MC9S12 Hardware Subsystems Setting and clearing bits in C Using pointers in C o Program to count the number of negative numbers in an area of memory Introduction to the MC9S12 Hardware Subsystems o The MC9S12 timer subsystem Operators

More information

Interrupt vectors for the 68HC912B32. The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF.

Interrupt vectors for the 68HC912B32. The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF. Interrupts The Real Time Interrupt Interrupt vectors for the 68HC912B32 The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF. These vectors are programmed into Flash EEPROM

More information

UM MPT612 User manual. Document information

UM MPT612 User manual. Document information Rev. 1 16 December 2011 User manual Document information Info Keywords Abstract Content ARM, ARM7, embedded, 32-bit, MPPT, MPT612 This document describes all aspects of the MPT612, an IC designed for applications

More information

What happens when an HC12 gets in unmasked interrupt:

What happens when an HC12 gets in unmasked interrupt: What happens when an HC12 gets in unmasked interrupt: 1. Completes current instruction 2. Clears instruction queue 3. Calculates return address 4. Stacks return address and contents of CPU registers 5.

More information

LABORATORY MANUAL EMBEDDED C LABORATORY. M. Tech I Year I Sem R13 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

LABORATORY MANUAL EMBEDDED C LABORATORY. M. Tech I Year I Sem R13 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG. LABORATORY MANUAL EMBEDDED C LABORATORY M. Tech I Year I Sem R13 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG. BALAJI INSTITUTE OF TECHNOLOGY & SCIENCE Laknepally, Narsampet, Warangal 1 M.TECH. (EMBEDDED

More information

ARM HOW-TO GUIDE Interfacing Relay with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Relay with LPC2148 ARM ARM HOW-TO GUIDE Interfacing Relay with LPC48 ARM Contents at a Glance ARM7 LPC48 Primer Board... Relay... Interfacing Relays... 4 Interfacing Relay with LPC48... 5 Pin Assignment with LPC48... 5 Circuit

More information

ECE551 Midterm Version 2

ECE551 Midterm Version 2 Name: ECE551 Midterm Version 2 NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual

More information

(Embedded) Systems Programming Overview

(Embedded) Systems Programming Overview System Programming Issues EE 357 Unit 10a (Embedded) Systems Programming Overview Embedded systems programming g have different design requirements than general purpose computers like PC s I/O Electro-mechanical

More information

Standard C Library Functions

Standard C Library Functions Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

ARM HOW-TO GUIDE Interfacing 7SEG with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing 7SEG with LPC2148 ARM ARM HOW-TO GUIDE Interfacing 7SEG with LPC2148 ARM Contents at a Glance ARM7 LPC2148 Slicker Board... 3 Seven Segment Display... 3 Interfacing Seven Segment Display... 4 Interfacing Seven Segment with

More information

UM10139 Volume 1: LPC214x User Manual

UM10139 Volume 1: LPC214x User Manual : LPC214x User Manual Rev. 01 15 August 2005 User manual Document information Info Keywords Abstract Content LPC2141, LPC2142, LPC2144, LPC2146, LPC2148, LPC2000, LPC214x, ARM, ARM7, embedded, 32-bit,

More information

E85 Lab 8: Assembly Language

E85 Lab 8: Assembly Language E85 Lab 8: Assembly Language E85 Spring 2016 Due: 4/6/16 Overview: This lab is focused on assembly programming. Assembly language serves as a bridge between the machine code we will need to understand

More information

Lab 3b: Scheduling Multithreaded Applications with RTX & uvision

Lab 3b: Scheduling Multithreaded Applications with RTX & uvision COE718: Embedded System Design Lab 3b: Scheduling Multithreaded Applications with RTX & uvision 1. Objectives The purpose of this lab is to introduce students to RTX based multithreaded applications using

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

EMBEDDED Systems. Functions. MODULE- 1 C programming with data Structure Introduction to C. Array and String. Control Flow Statements In C

EMBEDDED Systems. Functions. MODULE- 1 C programming with data Structure Introduction to C. Array and String. Control Flow Statements In C EMBEDDED Systems MODULE- 1 C with data Structure Introduction to C Objectives of C Applications of C Relational and logical operators Bit wise operators The assignment statement Intermixing of data types

More information

Bare Metal Application Design, Interrupts & Timers

Bare Metal Application Design, Interrupts & Timers Topics 1) How does hardware notify software of an event? Bare Metal Application Design, Interrupts & Timers 2) What architectural design is used for bare metal? 3) How can we get accurate timing? 4) How

More information

Implementing In-Application Programming on the ADuC702x

Implementing In-Application Programming on the ADuC702x Implementing In-Application Programming on the ADuC702x By Johnson Jiao [Johnson.Jiao@analog.com] and Raven Xue [Raven.Xue@analog.com] Background The ADuC702x Precision Analog Microcontroller provides

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

AN LPC2138 extreme power down application note. Document information. LPC2138, extreme power down

AN LPC2138 extreme power down application note. Document information. LPC2138, extreme power down application note Rev. 01 6 December 2006 Application note Document information Info Keywords Abstract Content LPC2138, extreme power down This document describes a method to power down the LPC2138 so the

More information

Input / Output Functions

Input / Output Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain

More information

AN HI-3200 Avionics Data Management Engine Evaluation Board Software Guide

AN HI-3200 Avionics Data Management Engine Evaluation Board Software Guide August 12, 2011 AN - 166 HI-3200 Avionics Data Management Engine Evaluation Board Software Guide Introduction This application note provides more detail on the HI-3200 demo software provided in the Holt

More information

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller 1 Salient Features (1). 8 bit microcontroller originally developed by Intel in 1980. (2). High-performance CMOS Technology. (3). Contains Total 40 pins. (4). Address bus is of 16 bit

More information

Embedded programming, AVR intro

Embedded programming, AVR intro Applied mechatronics, Lab project Embedded programming, AVR intro Sven Gestegård Robertz Department of Computer Science, Lund University 2017 Outline 1 Low-level programming Bitwise operators Masking and

More information

Advanced Embedded Systems

Advanced Embedded Systems Advanced Embedded Systems Practical & Professional Training on Advanced Embedded System Course Objectives : 1. To provide professional and industrial standard training which will help the students to get

More information

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller The 8051, Motorola and PIC families are the 3 leading sellers in the microcontroller market. The 8051 microcontroller was originally developed by Intel in the late 1970 s. Today many

More information

CMS-8GP32. A Motorola MC68HC908GP32 Microcontroller Board. xiom anufacturing

CMS-8GP32. A Motorola MC68HC908GP32 Microcontroller Board. xiom anufacturing CMS-8GP32 A Motorola MC68HC908GP32 Microcontroller Board xiom anufacturing 2000 717 Lingco Dr., Suite 209 Richardson, TX 75081 (972) 994-9676 FAX (972) 994-9170 email: Gary@axman.com web: http://www.axman.com

More information

Input/Output and the Operating Systems

Input/Output and the Operating Systems Input/Output and the Operating Systems Fall 2015 Jinkyu Jeong (jinkyu@skku.edu) 1 I/O Functions Formatted I/O printf( ) and scanf( ) fprintf( ) and fscanf( ) sprintf( ) and sscanf( ) int printf(const char*

More information

Microcontroller Introduction

Microcontroller Introduction Microcontroller Introduction Embedded Systems 2-1 Data Formats for the Renesas Microcontroller Byte Word 8 bits signed & unsigned unsigned range 0 to 255 unsigned char a; 16 bits signed & unsigned unsigned

More information

EECS 373 Midterm 2 Fall 2018

EECS 373 Midterm 2 Fall 2018 EECS 373 Midterm 2 Fall 2018 Name: unique name: Sign the honor code: I have neither given nor received aid on this exam nor observed anyone else doing so. Nor did I discuss this exam with anyone after

More information

LAB4. Program the on chip SPI module

LAB4. Program the on chip SPI module LAB4 Program the on chip SPI module Outline Learn to utilize the on-chip SPI module Implement it in C Translate it to ARM Assembly Test and verify the result using oscilloscope and shift register. Serial

More information

Pointers cause EVERYBODY problems at some time or another. char x[10] or char y[8][10] or char z[9][9][9] etc.

Pointers cause EVERYBODY problems at some time or another. char x[10] or char y[8][10] or char z[9][9][9] etc. Compound Statements So far, we ve mentioned statements or expressions, often we want to perform several in an selection or repetition. In those cases we group statements with braces: i.e. statement; statement;

More information

CSci 4061 Introduction to Operating Systems. Input/Output: High-level

CSci 4061 Introduction to Operating Systems. Input/Output: High-level CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device

More information

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks). Understanding FAT 12 You need to address many details to solve this problem. The exercise is broken down into parts to reduce the overall complexity of the problem: Part A: Construct the command to list

More information

ARM Architecture and Assembly Programming Intro

ARM Architecture and Assembly Programming Intro ARM Architecture and Assembly Programming Intro Instructors: Dr. Phillip Jones http://class.ece.iastate.edu/cpre288 1 Announcements HW9: Due Sunday 11/5 (midnight) Lab 9: object detection lab Give TAs

More information

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University Outline Introduction NVIC and Interrupt Control Interrupt

More information

Introduction to C Language

Introduction to C Language Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,

More information

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II Department of Electrical and Computing Engineering UNIVERSITY OF CONNECTICUT ECE 3411 Microprocessor Application Lab: Fall 2015 Quiz II There are 5 questions in this quiz. There are 9 pages in this quiz

More information

C Language Programming, Interrupts and Timer Hardware

C Language Programming, Interrupts and Timer Hardware C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and

More information

C Language Programming, Interrupts and Timer Hardware

C Language Programming, Interrupts and Timer Hardware C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and

More information

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab By the end of Class Pseudo-code for Lab 1-2 due as part of prelab Homework #5 on website due before next class Outline Introduce Lab 1-2 Counting Timers on C8051 Interrupts Laboratory Worksheet #05 Copy

More information

C Basics And Concepts Input And Output

C Basics And Concepts Input And Output C Basics And Concepts Input And Output Report Working group scientific computing Department of informatics Faculty of mathematics, informatics and natural sciences University of Hamburg Written by: Marcus

More information

Magic 8 Ball. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Magic 8 Ball. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name MPS Magic 8 Ball Lab Exercise Magic 8 Ball Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name Notes: You must work on this assignment with your partner. Hand in a printer

More information

University of Texas at El Paso Electrical and Computer Engineering Department

University of Texas at El Paso Electrical and Computer Engineering Department University of Texas at El Paso Electrical and Computer Engineering Department EE 3176 Laboratory for Microprocessors I Fall 2016 LAB 07 Flash Controller Goals: Bonus: Pre Lab Questions: Familiarize yourself

More information

5x7 LED Matrix Display with Z8 Encore! XP

5x7 LED Matrix Display with Z8 Encore! XP Application Note 5x7 LED Matrix Display with Z8 Encore! XP AN014402 1207 Abstract This application note explains the method to use Zilog s Z8 Encore! XP microcontroller s General-Purpose Input/Output (GPIO)

More information

1 The CTIE processor INTRODUCTION 1

1 The CTIE processor INTRODUCTION 1 1 The CTIE processor INTRODUCTION 1 1. Introduction. Whenever a programmer wants to change a given WEB or CWEB program (referred to as a WEB program throughout this program) because of system dependencies,

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

User Manual For CP-JR ARM7 USB-LPC2148 / EXP

User Manual For CP-JR ARM7 USB-LPC2148 / EXP CP-JR ARM7 USB-LPC2148 / EXP 38 CR-JR ARM7 USB-LPC2148 which is a Board Microcontroller ARM7TDMI-S Core uses Microcontroller 16/32-Bit 64 Pin as Low Power type to be a permanent MCU on board and uses MCU

More information