No.82599 作者:gfc2003 邮件:gfc2003.student@sina.com ID:39291 登陆:2次 文章数:1篇 最后登陆IP:59.41.216.20 最后登陆:2007/4/14 16:35:57 注册:2005/8/23 10:43:24 财富:106 发帖时间:2005/8/23 10:45:56 发贴者IP:61.187.92.238 标题:gfc2003:急求高手帮助!此程序为020UART1的异步串行双机通信,但不能正常通信! 摘要:No.82599急求高手帮助!此程序为020UART1的异步串行双机通信,但不能正常通信! #include <c8051f020.h> // SFR declarations #include <stdio.h> #include <intrins.h> #define PRT0CF P0MDOUT #define PRT1CF P1MDOUT #define PRT2CF P2MDOUT #define BAUDRATE 115200 // 串口波特率(bps); #define MUX_volt 0x01 #define uchar unsigned char unsigned int w; long volt; sfr16 ADC0 = 0xbe; // ADC0 data uchar idata buf[6]; uchar sum; //----------------------------------------------------------------------------- /* 初始化程序 */ //----------------------------------------------------------------------------- void Delay1us(unsigned char us) { while (us) { _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); --us; } } // 延时1us void SYSCLK_Init (void) { int i; // delay counter OSCXCN = 0x67; // start external oscillator with // 18.432MHz crystal for (i=0; i < 256; i++) ; // Wait for osc. to start up while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle OSCICN = 0x88; // select external oscillator as SYSCLK // source and enable missing clock // detector // OSCICN = 0x07; //interal 16MHZ } void PORT_Init (void) { XBR0 = 0x07; // Enable SMBus, SPI0, and UART0 XBR1 = 0x00; XBR2 = 0x44; // Enable crossbar and weak pull-ups EMI0TC = 0x21; P74OUT = 0xFF; P0MDOUT = 0x15; P1MDOUT |= 0x3d; //P1.2-P1.5推挽输出 P1 &= 0xc3; //P1.2-P1.5=0 } //----------------------------------------------------------------------------- /* ADC0初始化 */ //----------------------------------------------------------------------------- void init_adc(void) { ADC0CN = 0x81; // ADC0 enabled; normal tracking // mode; ADC0 conversions are initiated // on write to AD0BUSY; ADC0 data is // left-justified REF0CN = 0x07; // enable temp sensor ......
>>返回讨论的主题
|