int main() { rtc_t rtc; SystemInit(); UART0_Init(9600); RTC_Init(); rtc.hour = 10; // 10:40:20 am rtc.min = 40; rtc.sec = 0; rtc.date = 1; //1st Jan 2016 rtc.month = 1; rtc.year = 2016; rtc.weekDay = 5; // Friday: 5th day of week considering monday as first day. /*##### Set the time and Date only once. Once the Time and Date is set, comment these lines and reflash the code. Else the time will be set every time the controller is reset*/ RTC_SetDateTime(&rtc); // 10:40:20 am, 1st Jan 2016 /* Display the Time and Date continuously */ while(1) { RTC_GetDateTime(&rtc); UART0_Printf("\n\rtime:%2d:%2d:%2d Date:%2d/%2d/%4d",(uint16_t)rtc.hour,(uint16_t)rtc.min,(uint16_t)rtc.sec,(uint16_t)rtc.date,(uint16_t)rtc.month,(uint16_t)rtc.year); } }
/* start the main program */ int main() { uint8_t eeprom_address = 0x00, write_str[] = "Welcome to LPC1768 programming by Explore Embedded"; uint8_t read_str[50]; UART0_Init(9600); UART0_Printf("\n\rEeprom Write String: %s", write_str); //Print the message on UART EEPROM_WriteString(eeprom_address, write_str); // Write the string at memoryLocation 0x00 EEPROM_ReadString(eeprom_address, read_str); // Read the string from memoryLocation 0x00 UART0_Printf("\n\rEeprom Read String: %s", read_str); //Print the message on UART while (1); }
int main() { UART0_Init(9600); SystemInit(); while(1) { UART0_Printf("Welcome to ARM Serial Programming by ExploreEmbedded\n\r"); } }
int main() { uint8_t key; SystemInit(); UART0_Init(9600); // Initialize UART0 at 9600 baud rate KEYPAD_Init(P2_0,P2_1,P2_2,P2_3,P2_4,P2_5,P2_6,P2_7); // Keypad is connected to P2_0 - P2_7 while (1) { key = KEYPAD_GetKey(); // Read the Ascii value of Key UART0_Printf("\n\r Key:%c", key); // Transmit the key pressed on UART } }
int main() { int adcValue; float volt; SystemInit(); ADC_Init(); /* Initialize the ADC module */ UART0_Init(9600); /* Initialize UART at 9600 baud rate */ while(1) { adcValue = ADC_GetAdcValue(0); // Read the ADC value of channel zero volt = (adcValue*(float)3.3)/(float)1023; UART0_Printf("ADC0 Value:%4d Equivalent Voltage:%f\n\r",adcValue,volt); // Send the value on UART } }
int main() { int adcValue; SystemInit(); ADC_Init(); /* Initialize the ADC module */ UART0_Init(9600); /* Initialize UART at 9600 baud rate */ while(1) { adcValue = ADC_GetAdcValue(AD0_1); // Read the ADC value of ADC0_1 UART0_Printf("ADC0 Value:%4d \n\r",adcValue); // Send the value on UART } }
int main() { int adcValue,temp; SystemInit(); ADC_Init(); /* Initialize the ADC module */ UART0_Init(9600); /* Initialize UART at 9600 baud rate */ while(1) { adcValue = ADC_GetAdcValue(AD0_1); // Read the ADC value of channel zero where the temperature sensor(LM35) is connected /* Convert the raw ADC value to equivalent temperature with 3.3v as ADC reference Step size of AdC= (3.3v/1023)= 3.225mv. for every degree celcius the Lm35 provides 10mv voltage change. 1 step of ADC=3.225mv=0.5'c, hence the Raw ADC value can be divided by 3.1 to get equivalent temp*/ temp = adcValue/(float)3.1; // Divide by 3.1 to get the temp value. UART0_Printf("ADC0 Value:%4d Equivalent Temperature:%3d\n\r",adcValue,temp); // Send the value on UART } }
int main() { char str[50]; int len = 0; SystemInit(); /*Connect RS->P1_16, RW->P1_17, EN->P1_18 and data bus(D4:D7 - P1_20:P1_23)*/ LCD_SetUp(P1_16,P1_17,P1_18,P_NC,P_NC,P_NC,P_NC,P1_20,P1_21,P1_22,P1_23); LCD_Init(2,16); UART0_Init(9600); LCD_DisplayString("send data from serial terminal"); while(1) { len = UART0_RxString(str); UART0_Printf("Received String:%s size=%2d\n\r",str,len); LCD_Clear(); LCD_Printf("str:%s size=%2d",str,len); } }