Hello folks, need help again, I am using an Atmega32u4 and 2 UHF data transceiver(http://www.e-gizmo.com/KIT/images/uhfdatatranciever/5812A%20Tech%20Manual.pdf.
I am trying to transmit data from Atmega32u4 to one of this transceiver then to another transceiver serves as the receiver, connected to PC. When I tried to view my result, used the terminal program(Terminal V.1.9b),I got nothing. When I tried to connect the Atmega 32u4 directly to PC, I got the expected output. My set-up is attached.
https://www.avrfreaks.net/modules/PNphpBB2/files/circuit_diagram_175.jpg
I already check the properties. My thoughts is that the problem is in the set-up or in my code. My mentor said that I dont have to load a program on the receiver anymore. Here is my code to my Atmega.
#define F_CPU 16000000UL #define BAUDRATE 9600 #define BAUD_PRESCALLER (((F_CPU / (BAUDRATE * 16UL))) - 1) #include#include //Declaration of functions void USART_init(void); unsigned char USART_receive(void); void USART_send(unsigned char data); void USART_putstring(char* StringPtr); /*message arrays*/ char msg1[] = {"The water is in level 1."}; char msg2[] = {"The water is in level 2."}; char msg3[] = {"The water is in level 3."}; char msg4[] = {"The water is in level 4."}; char msg5[] = {"No switch is on/Error!"}; int main(void) { DDRB = 0x00; /*set PortB as input*/ PORTB = 0x00; USART_init(); while(1) //Infinite loop { if (PINB & 0x08) { USART_putstring(msg4); _delay_ms(5000);} else if (PINB & 0x04) { USART_putstring(msg3); _delay_ms(5000); } else if (PINB & 0x02) { USART_putstring(msg2); _delay_ms(5000); } else if (PINB & 0x01) { USART_putstring(msg1); _delay_ms(5000); } else { USART_putstring(msg5); _delay_ms(5000); } } } void USART_send(unsigned char data){ while(!(UCSR1A & (1<<UDRE1))); UDR1 = data; } void USART_putstring(char* StringPtr){ while(*StringPtr != 0x00){ USART_send(*StringPtr); StringPtr++;} } void USART_init(void){ UBRR1H = (uint8_t)(BAUD_PRESCALLER >> 8); UBRR1L = (uint8_t)(BAUD_PRESCALLER); UCSR1B = (1 << TXEN1) | (1 << RXEN1); UCSR1C = (1 << UCSZ11) | (1 << UCSZ10); } unsigned char USART_receive(void){ while(!(UCSR1A & (1<<RXC1))); return UDR1; }
Any help why I cant received data using the transceiver? or my set-up is incorrect?
Thank you in advanced.