|
From: | Kreyl |
Subject: | Re: [avr-chat] Fwd: First step |
Date: | Mon, 8 Feb 2010 00:44:31 +0300 |
-------- Original Message --------
Hello everyone! Help make the first steps in the avr-libs. I can not accept data from USART # define F_CPU 20000000UL # include <avr/io.h> # include <avr/interrupt.h> void port_init (void) ( PORTA = 0x00; DDRA = 0x00; PORTB = 0x00; DDRB = 0x00; PORTD = 0x00; DDRD = 0x00; ) / / Desired baud rate: 2400 / / Actual: baud rate: 2399 (0.0%) void usart_init (void) ( UCSRB = 0x00; / / disable while setting baud rate UBRRH = 0x02; / / set baud rate upper UBRRL = 0x08; / / set baud rate lower UCSRA = 0x00; UCSRC = 0x06; UCSRB = 0x98; / / enable ) void init_devices (void) ( cli (); / / disable all interrupts port_init (); usart_init (); MCUCR = 0x00; GIMSK = 0x00; TIMSK = 0x00; sei (); / / re-enable interrupts ) void usart_transmit (unsigned char data) ( while (! (UCSRA & (1 <<UDRE))) ; UDR = data; ) unsigned char usart_receive (void) ( while (! (UCSRA & (1 <<RXC))) ; return UDR; ) int main (void) ( unsigned char data; init_devices (); data = "" (); usart_transmit ('+'); return 0; ) when sending data from the computer it does not respond. but the following code works correctly and I get the data from the controller. int main (void) ( init_devices (); usart_transmit ('+'); return 0; ) why can not I accept this? __________ Information from ESET NOD32 Antivirus, version of virus signature database 4845 (20100207) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com |
[Prev in Thread] | Current Thread | [Next in Thread] |