Posts

Showing posts with the label 18CSL48

MICROCONTROLLER AND EMBEDDED SYSTEMS LABORATORY Part B

Image
 Program 9 Display “Hello World” message using Internal UART. #include<lpc21xx.h> void Uart0Init(void) //initialize serial interface { PINSEL0=0X00000005; // enable RXD0 (P0.1) & TXD0 (P0.0) U0LCR = 0X83; // 8 bits, no parity, 1 stop bit U0DLL = 97; // 9600 Baud rate @ 15MHz PCLK U0LCR = 0X03; // DLAB = 0 } void Uart0PutCh(unsigned char ch) //write char to serial port { U0THR = ch; // Transmission hold register while(!(U0LSR & 0x20)); //checking whether the Char is completely transmitted, // TX= 0 or 1 // if tx bit =1 , complete transmission of a char to PC has been done } void uart_print(char *a) { int i; for(i=0;a[i]!='\0';i++) Uart0PutCh(a[i]); //one char at a time is transmitted using this function } int main() { Uart0Init(); // function call to initialize LPC2148 uart_print("Hello World"); // function call to transmit the data to PC } Program explanation and Demo:  UART  Program 10  Interface and Control a DC Motor.  //#define MOTOR 0x00000060...

MICROCONTROLLER AND EMBEDDED SYSTEMS LABORATORY Part A

Image
1. Write a program to multiply two 16 bit binary numbers. Program:  area multiply, code, readonly entry ldr r5,=value1 ldrh r0,[r5]  ldr r6,=value2 ldrh r1,[r6] mul r3,r1,r0 stop b stop value1 DCD 0x08 value2 DCD 0x03 end Program explanation and Demo:  MCES Lab 1 2. Write a program to find the sum of first 10 integer numbers. Program: AREA ADDITION, CODE, READONLY ENTRY ;MARK FIRST INSTRUCTION TO EXECUTE MOV r0, #10 ; STORE INTEGER NUMBER IN R0 MOV r1,r0  ADDIT SUBS r1, r1, #1 ; SUBTRACTION CMP r1, #0 ; COMPARISON BEQ DONE ADD r3,r0,r1 ; ADDITION MOV r0,r3 ; RESULT     BNE ADDIT ; BRANCH TO THE LOOP IF NOT EQUAL DONE LDR R4,=RES STR R0,[R4]   LDR R5,[R4] STOP B STOP AREA DATA1,DATA,READWRITE RES DCD 0X000 END ;MARK END OF FILE Program explanation and Demo:  MCES Lab 2      3. Write a program to find factorial of a number. Program :  AREA FACT,READONLY,CODE ;Write ...