Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

xmega USART transmition problem

Status
Not open for further replies.

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.

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 ******
 

Are you sure you need to send 13 + 10, and not only 10 ? This could be worth of a try.
At the moment I have no further suggestions
 

Thanks for your reply.
I tried many hours on this system and I found out on system start-up one or some characters went into COZIR. I don't know yet if it is from COZIR or xmega!
So after first submit by \r\n it will see some unknown command, After that the other command work well.
 

Thanks for reply.
I pullup the tx and problem solved.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top