1、rs485 通讯程序接收 0123456789,只接收不发送,使用 LM1602 液晶显示2008-12-07 19:45#include #include #include #include/液晶为 JDH162A 1602 液晶 16*2/以下宏定义语句可根据实际情况更改#define dataport PORTB#define datapin PINB#define dataddr DDRB#define conport PORTA#define conddr DDRA#define rw PA5#define rs PA6#define e PA4unsigned char str1=
2、“Waiting.“;volatile int num;/中断接收函数ISR(USART_RXC_vect)writelocatechar(num,0,UDR);num+;unsigned char isbusy(void)unsigned char tmp;conporti-)writelocatechar(x+i-1,y,(*p+48);p+;void port_init(void)PORTA = 0x00;DDRA = 0xFF;PORTB = 0x00;DDRB = 0x00;PORTC = 0x00; /m103 output onlyDDRC = 0x00;PORTD = 0x00
3、;DDRD = 0x00;/call this routine to initialize all peripheralsvoid init_devices(void)/stop errant interrupts until set upasm(“cli“); /disable all interruptsport_init();MCUCR = 0x00;GICR = 0x00;TIMSK = 0x00; /timer interrupt sourcesasm(“sei“); /re-enable interrupts/all peripherals are now initializedint main()init_devices();init_lcd();writecom(0x01,1);/清除屏幕 num=0; uart_init(0x00,0x17);asm(“sei“);while(1);