Author Topic: ask: UART Communication  (Read 1223 times)

0 Members and 1 Guest are viewing this topic.

Offline frans3qTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
ask: UART Communication
« on: August 26, 2009, 08:52:16 AM »
hi. i'm just start learning about robotic. I'm using AT Mega 8535 uC.
i want to send data from PC to uC then i give time to uC to process the data.
but i want to make it when i repeat the input and the uC havnt finish the calculation before yet. then the recent data is doesnt count. i dont want make the data queuing. just delete the data transfered from PC if the uC havnt finish the calculation for the prev data.
how do i check if the uC is in busy or ready state to receive data. is there a port that indicate that? i hve searching the data sheet. but i didnt found about that, i dont know, may be i search for the wrong key word.

sorry for bad english. hope u still understand what i mean.

Offline arixrobotics

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
Re: ask: UART Communication
« Reply #1 on: August 26, 2009, 09:11:11 AM »
hmm how about if you have the PC to send a "Are u ready?" signal to the uC before every new data transfer? If the uC is ready, it should reply and the PC should proceed with the data transfer. If the uC is doing some calculations, it should not reply at all, then the PC's uart would timeout.

That means you will need to enable uart only when the uC is not doing any calculations. When it is doing something, disable uart so that it does not get interrupted.

Offline Half Shell

  • Robot Overlord
  • ****
  • Posts: 225
  • Helpful? 0
Re: ask: UART Communication
« Reply #2 on: August 26, 2009, 07:46:24 PM »
hmm how about if you have the PC to send a "Are u ready?" signal to the uC before every new data transfer? If the uC is ready, it should reply and the PC should proceed with the data transfer. If the uC is doing some calculations, it should not reply at all, then the PC's uart would timeout.

That means you will need to enable uart only when the uC is not doing any calculations. When it is doing something, disable uart so that it does not get interrupted.

Actually, the "Are you ready?" signal is often how it is done. You simply send a byte of a handful of bytes that lets the micro controller know that you want information and what information you want.

One thing I'd like to point out though that you probably won't have to worry about a timeout because the micro controller is calculating. Serial communication on micro controllers is interrupt driven, meaning that the controller will pause its current calculation and return the data it has, and then deal with the serial request. This will be done at such a high rate that even a small timeout of a fraction of a second is more than enough time for the micro controller to respond.

If you need help just post.

Offline frans3qTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: ask: UART Communication
« Reply #3 on: August 27, 2009, 05:02:23 AM »
hmm... i'm thinking that the ready signal should be send from uC. when the uC didnt do anything such as drive a motor or else, it send ready signal to PC repeatedly.

 


Get Your Ad Here