资源描述:
《广石化嵌入式试卷a卷.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include"LPC11xx.h"#include"adc.h"#include"uart.h"externvolatileuint32_tADCValue;externvolatileuint32_tADCIntDone;externvolatileuint32_tUARTCount;externvolatileuint32_tUARTBuffer[10];uint8_tConvertDigital(uint8_tdigital){uint8_tascii_char;if((digital>='A')&&(digital<='F')){asci
2、i_char=digital-0x0A;ascii_char+=0x41;}else{ascii_char=digital+0x30;}return(ascii_char);}intmain(void){uint32_ti;SystemInit();UARTInit(115200);ADCInit(ADC_CLK);while(1){ADCValue=ADCRead(1);LPC_UART->IER=IER_THRE
3、IER_RLS;UARTBuffer[0]=ConvertDigital((uint8_t)(ADCValue>>28));UARTB
4、uffer[1]=ConvertDigital((uint8_t)(ADCValue>>24)&0xF);UARTBuffer[2]=ConvertDigital((uint8_t)(ADCValue>>20)&0xF);UARTBuffer[3]=ConvertDigital((uint8_t)(ADCValue>>16)&0xF);UARTBuffer[4]=ConvertDigital((uint8_t)(ADCValue>>12)&0xF);UARTBuffer[5]=ConvertDigital((uint8_t)(ADCValue>>8)
5、&0xF);UARTBuffer[6]=ConvertDigital((uint8_t)(ADCValue>>4)&0xF);UARTBuffer[7]=ConvertDigital((uint8_t)ADCValue&0xF);UARTBuffer[8]='r';UARTBuffer[9]='';UARTSend((uint8_t*)UARTBuffer,10);LPC_UART->IER=IER_THRE
6、IER_RLS
7、IER_RBRfor(i=0;i<0x888888;i++);}}#include"LPC11xx.h"#include
8、"lpc_types.h"#include"LPC11xx_clkpwr.h"#include"LPC11xx_gpio.h"intmain(void){unsignedinti;GPIO_SetDir(0,4,1);GPIO_SetDir(0,5,1);GPIO_SetDir(0,6,1);GPIO_SetDir(0,7,1);while(1){GPIO_SetValue(0,4,0);GPIO_SetValue(0,5,1);GPIO_SetValue(0,6,1);GPIO_SetValue(0,7,1);for(i=0;i<0xFFFF;i+
9、+);GPIO_SetValue(0,4,1);GPIO_SetValue(0,5,0);GPIO_SetValue(0,6,1);GPIO_SetValue(0,7,1);for(i=0;i<0xFFFF;i++);GPIO_SetValue(0,4,1);GPIO_SetValue(0,5,1);GPIO_SetValue(0,6,0);GPIO_SetValue(0,7,1);for(i=0;i<0xFFFF;i++);GPIO_SetValue(0,4,1);GPIO_SetValue(0,5,1);GPIO_SetValue(0,6,1);
10、GPIO_SetValue(0,7,0);for(i=0;i<0xFFFF;i++);}}#include"LPC11xx.h"#include"timer32.h"#include"gpio.h"externvolatileuint32_ttimer32_1_counter;intmain(void){SystemInit();init_timer32(1,TIME_INTERVAL);enable_timer32(1);LPC_SYSCON->SYSAHBCLKCTRL
11、=(1<<6);GPIOSetDir(2,0,1);GPIOSetDir(2
12、,1,1);while(1){if((timer32_1_counter>0)&&(timer32_1_co