Sharagim
Advanced Member level 4
- Joined
- Feb 6, 2011
- Messages
- 112
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Activity points
- 2,058
Hi,
I have an Atxmega128A3U , and a CO2 sensor (COZIR) which is UART.
Sensor is connected to PORTF. On PORTC I made an RS232 connection.
In my code I made a bridge between these two which pass through between PORTC to PORTF.
When I send command from PC to micro it is working ok I mean I send to micro and micro send to sensor I see correct reply from sensor.
But When micro directly sending from its own I see wrong reply and Sesor saying "command is unrecognized".
I checked from micro output with PC and I see in terminal it is ok and the character is what I want.
I tested on both 2 and 32 MHZ.
I have an Atxmega128A3U , and a CO2 sensor (COZIR) which is UART.
Sensor is connected to PORTF. On PORTC I made an RS232 connection.
In my code I made a bridge between these two which pass through between PORTC to PORTF.
When I send command from PC to micro it is working ok I mean I send to micro and micro send to sensor I see correct reply from sensor.
But When micro directly sending from its own I see wrong reply and Sesor saying "command is unrecognized".
I checked from micro output with PC and I see in terminal it is ok and the character is what I want.
I tested on both 2 and 32 MHZ.
Code:
PORTF.DIRSET = PIN3_bm;
PORTF.DIRCLR = PIN2_bm;
USART_InterruptDriver_Initialize(&USART_data1, &USART1, USART_DREINTLVL_LO_gc);
USART_Format_Set(USART_data1.usart, USART_CHSIZE_8BIT_gc,USART_PMODE_DISABLED_gc, false);
USART_RxdInterruptLevel_Set(USART_data1.usart, USART_RXCINTLVL_LO_gc);
USART_Baudrate_Set(&USART1, 207 , 0);
USART_Rx_Enable(USART_data1.usart);
USART_Tx_Enable(USART_data1.usart);
PMIC.CTRL |= PMIC_LOLVLEX_bm;
sei();
while (!(USART_IsTXDataRegisterEmpty(USART_data1.usart))){}
USART_PutChar(&USART1, (int)'Y');
while (!(USART_IsTXDataRegisterEmpty(USART_data1.usart))){}
USART_PutChar(&USART1, 13);
while (!(USART_IsTXDataRegisterEmpty(USART_data1.usart))){}
USART_PutChar(&USART1, 10);
while (!(USART_IsTXDataRegisterEmpty(USART_data1.usart))){}
****** I am getting wrong reply ******