Forum Replies Created
Viewing 1 post (of 1 total)
-
AuthorPosts
-
usmanParticipantHi, this is what I m doing but unsuccessful…#define USART_BAUDRATE 57600#define F_CPU 8000000#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16))) – 1)//this is the packet i want to transmit. I have define the array as:char GenImg[12] = { 0xEF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x03, 0x01, 0x00, 0x05 };//I have called in the main these functions:usart_init();_delay_ms(500);_delay_ms(500);send_bytes(GenImg,12);//this function is for “initialization of usart”:void usart_init(){UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitryUCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);// Use 8-bit character sizesUCSRC &= ~(1 << UMSEL); // In UCSRC, UMSEL = 0 for asynchronousUCSRC &= ~(1<<USBS); //In UCSRC, USBS = 0 => 1 stop bitUBRRL = BAUD_PRESCALE;// Load lower 8-bits of the baud rate value into the low byte of the UBRR registerUBRRH = (BAUD_PRESCALE >> ; // Load upper 8-bits of the baud rate value..// into the high byte of the UBRR register}//this is function for transmitting:void send_bytes(char *s, int length){while (length–){usart_transmit(*s);s++;}}void usart_transmit(unsigned char c){while(!(UCSRA & (1 << UDRE))); // wait until UDR readyUDR = c; // send character}Please help me to correct any errors!
-
AuthorPosts
Viewing 1 post (of 1 total)