-1

I am using the USART in synchronous mode to communicate from the host computer to firmware(resides in ATMega 1284P). My maximum buffer size in the firmware side is 20, If I send the data continuously from the host to the firmware and some replies from firmware to host computer, somehow the communication locks up. I doubt that the UDR register which is common for both Transmit Data Buffer(TXB) and Receive Data Buffer(RXB) to send/receive the data in/out of the firmware is locked which results in ceasing of communication. Any Suggestion for this issue?

PS: For transmisson from firmware to host, the codition is: UCSRA & (1 << UDRE) should be TRUE

For reception from host to firmware, the condition is: UCSRA & (1 << RXC) should be TRUE

I am using hardware interrupt M_USARTx_RX_vect for checking the availability of the serial characters from host.

Update: Firmware - Initial Source : MarlinSerial.cpp : USART Definitions, Marlin_main.cpp : Program Flow

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Nagarjun
  • 75
  • 1
  • 10
  • 3
    It is about embedded programming, how to use UART in atmega device. No network involved! – Klaus Sep 02 '14 at 11:50
  • Do you really mean "synchronous" mode? This always uses a separate clock line. If you communicate via rs232 to the pc, you have to use asynchronous mode! maybe the problem starts here ... – Klaus Sep 02 '14 at 11:52
  • No I am not using rs232, both the host(runs arch linux) and the controller are in two different boards bind together. so there is no cable involved. – Nagarjun Sep 02 '14 at 11:58
  • 1
    uhh - wait - a UART connection without a cable? Are your Bits carried by squirrels from TX of one to RX of the other board? – vlad_tepesch Sep 02 '14 at 14:18
  • @vlad_tepesch host cpu board is plugged into the mcu board. – Nagarjun Sep 02 '14 at 14:27
  • No source, no help! Sorry! If you are not able to provide the problematic parts of your code nobody can help you here. Have fun! – Klaus Sep 03 '14 at 07:32

1 Answers1

0

The UDR register is physically two times present at the same address in the avr address space ( special io register mapping). There is no locking between the udr of the rx and tx of the uasrt in hardware.

The shown conditions seems ok to me, but I have not looked in the avr datasheet.

Maybe you have some problems while writing/reading to your cyclic? 20 char buffer? Please show your code ( please shrink for the minimum we need to understand ).

Klaus
  • 24,205
  • 7
  • 58
  • 113
  • It is working perfectly fine, if I limit the data sent from host to firmware to be less than 20. And after that, based on the acknowledgment from firmware side to host, I send the further data. The buffers are of char type. The problem appears only if I continuously flow the data from host. Once it exceeds the limit of 20, the firmware stops responding(firmware cannot send acknowledgment and host is waiting for acknowledgment to send next data). – Nagarjun Sep 02 '14 at 12:18
  • 2
    so please you have to show us your code and maybe we can find the problem. I am not a specialist of remote analyzing a black box :-) – Klaus Sep 02 '14 at 12:47