Calculate time between received bytes

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Calculate time between received bytes

Post by Desdewit »

How do you calculate the time you have between received bytes to execute other commands when a pic is running with 19.606 MHz crystal and a baud rate of 9600?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Calculate time between received bytes

Post by Benj »

Hello,

A 8-bit PIC runs at 1/4th of the clock frequency so at 19.6608MHz the chip is running at 4.9152MHz.

4.9152MHz / (9600 / 10) = 20480 instructions between byte receptions.

I divided the baud rate by 10 because each 8-bit byte requires a start bit and a stop bit, eg 960 bytes per second @ 9600 baud.

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Calculate time between received bytes

Post by Desdewit »

Hi Ben

Thanks for the reply.
4.9152MHz / (9600 / 10) = 20480 instructions between byte receptions.
19660800 /960 = 20480 :?

Post Reply