Clock speed and communication

Thread Starter

anukalp

Joined Jul 28, 2018
141
Hi,

I done a project to interface the PIC16f877a and PC via uart . I can send data to Laptop and I can receive data from Laptop. I do not understand one thing in the experiment

What would be the data speed between PIC16F877A and Laptop?

Hope your can guide me on this.
 

AlbertHall

Joined Jun 4, 2014
8,551
When you set up the PIC UART and the PC serial comms you set the same speed on both (otherwise they will not understand each other). That is the data speed that will apply to the link.
 

Thread Starter

anukalp

Joined Jul 28, 2018
141
When you set up the PIC UART and the PC serial comms you set the same speed on both (otherwise they will not understand each other). That is the data speed that will apply to the link.
I had set up hyper terminal
Bit per second : 9600
Data bit :8
Parity : None
set up bit : 1

What would be speed of data transmission between PIC and laptop in hertz Hz
 

Attachments

jpanhalt

Joined Jan 18, 2008
8,129
Your "bits per second" is called Baud rate. Both sides will have a setting for that. 9600 baud is quite slow by today's standards but is still often used.

Is your "UART" an RS232-type (asynchronous) or SPI (synchronous) as discussed in other threads?

NB: Both types are discussed in the USART section of the datasheet (Section 10).
 
Last edited:

AlbertHall

Joined Jun 4, 2014
8,551
What would be speed of data transmission between PIC and laptop in hertz Hz
There will be 9600 bits transferred each second BUT when a UART sends a byte the eight data bits are accompanied by a start bit and one or two stop bits. So to send a byte, 10 or 11 bits need to be transferred.
 

Thread Starter

anukalp

Joined Jul 28, 2018
141
Is your "UART" an RS232-type (asynchronous) or SPI (synchronous) as discussed in other threads?
PiC Board had "UART" an RS232-type interface

I was trying to get speed in hertz Hz . I searched on google for a formula but I couldn't get it.

What's the formula to calculate data speed between PIC and PCB
 

jpanhalt

Joined Jan 18, 2008
8,129
At 9600 baud, each 8-bit character takes 104 us (1/9600). Actual bit rate (assuming a start and stop bit) is 10.4 us/bit (104 us per character/10 bits/character). That may vary depending on the protocol. (https://en.wikipedia.org/wiki/Baud )

Baud is "symbols per second" not bits per second. Unfortunately, the two are often used interchangeably in causal discussion. Hertz has little meaning related to that, if you are referring to the operating frequency of your PIC. That is discussed in Section 10 of the datasheet for the protocol you are using .
 

jpanhalt

Joined Jan 18, 2008
8,129
Actually, I was referring to the attachment in Post #3, as the implication of 9600 seemed to be "Baud;" although, it said "bits."
 

Thread Starter

anukalp

Joined Jul 28, 2018
141
At 9600 baud, each 8-bit character takes 104 us (1/9600). Actual bit rate (assuming a start and stop bit) is 10.4 us/bit (104 us per character/10 bits/character).
Thank you jpanhalt

one byte take 104 us to transfer data between PIC and laptop

How would we know speed if there is no baud rate. For example Real Time Clock https://electrosome.com/rtc-ds1307-pic-microcontroller/

ds1307 I2C device and 32.768 kHz crystal on the board

What Would be the transmission speed between PiC16f877a and DS1307 (Real time clock) ?
 

BobaMosfet

Joined Jul 1, 2009
839
Thank you jpanhalt

one byte take 104 us to transfer data between PIC and laptop

How would we know speed if there is no baud rate. For example Real Time Clock https://electrosome.com/rtc-ds1307-pic-microcontroller/

ds1307 I2C device and 32.768 kHz crystal on the board

What Would be the transmission speed between PiC16f877a and DS1307 (Real time clock) ?
I'm not sure why this is a difficult concept, given everyone else's responses. A Hertz means 'per Second'. so 1 Hertz is once per second. The rest is pretty self-explanatory.
 
Last edited:

Thread Starter

anukalp

Joined Jul 28, 2018
141
I'm not sure why this is a difficult concept, given everyone else's responses. A Hertz means 'per Second'. so 1 Hertz is once per second. The rest is pretty self-explanatory.
because both devices are working on different frequency PIC running with 20 Mz and ds1307 running with 32.768 kHz

why you are considering the frequency of only slave device
 

AlbertHall

Joined Jun 4, 2014
8,551
because both devices are working on different frequency PIC running with 20 Mz and ds1307 running with 32.768 kHz
For I2C communication the clock (typically 100kHz or 400kHz) comes from the master device and the slave device (in this case the DS1307) responds to that.
 

ericgibbs

Joined Jan 29, 2010
8,886
hi,
There seems to be some confusion over a 9600Baud character rate.

Sending eight bits of data per character with the required start and stop bits will take up 10 times the bit time for each byte sent.
At 9600 baud, the bit time is about 104 microseconds which makes each character sent take 1.04 milliseconds.
This corresponds to a transfer rate of about 960 bytes per second.

E
 

jpanhalt

Joined Jan 18, 2008
8,129
I'm not sure why this is a difficult concept, given everyone else's responses. A Hertz means 'per Second'. so 1 Hertz is once per second. The rest is pretty self-explanatory.
So, what is your answer for this:
What would be speed of data transmission between PIC and laptop in hertz Hz
BTW: The common definition of Hertz is one cycle per second.
 
Last edited:

MrChips

Joined Oct 2, 2009
19,425
Data speed and Hz are not convertible.
Hertz is cycles per second.
9600 baud is 9600 symbols per second or as discussed above, some equate it to 9600 bits per second.

The bandwidth required to transmit 9600 bits per second will far exceed 9600 Hz. There is no conversion formula available.
 

Thread Starter

anukalp

Joined Jul 28, 2018
141
Do you understand what I am asking because I don't think there is straight forward explanation for I2C Protocols. If you want a more information please let me know

I have one microcontroller pic16f877a and DS1307 worked on I2C protocols. Microcontroller is connected with 12MHz of external oscillator and DS1307 ds1307 running with 32.768 kHz.

Microcontroller sending data to Ds1307 and receiving data from DS1307 via I2C Protocol

What is speed of I2C communication between microcontroller and DS1307 ?
 

ericgibbs

Joined Jan 29, 2010
8,886
hi a,
The 32.768kHz xtal on the DS1307 is just for the real time clock, not for any command timing.
The MCU controls the timing on the I2C comms.
E

Update:

Added sample of a Basic DS1307 comms routines.
 

Attachments

Last edited:

jpanhalt

Joined Jan 18, 2008
8,129
Do you understand what I am asking because I don't think there is straight forward explanation for I2C Protocols. If you want a more information please let me know

I have one microcontroller pic16f877a and DS1307 worked on I2C protocols. Microcontroller is connected with 12MHz of external oscillator and DS1307 ds1307 running with 32.768 kHz.

Microcontroller sending data to Ds1307 and receiving data from DS1307 via I2C Protocol

What is speed of I2C communication between microcontroller and DS1307 ?
So far you seem to be talking about RS-232 (posts # 1, 3, 6, and 10). Which is it? Hardware I2C is controlled by the MSSP module (Section 9). "UART" is different (Section 10).
 

BobaMosfet

Joined Jul 1, 2009
839
Do you understand what I am asking because I don't think there is straight forward explanation for I2C Protocols. If you want a more information please let me know

I have one microcontroller pic16f877a and DS1307 worked on I2C protocols. Microcontroller is connected with 12MHz of external oscillator and DS1307 ds1307 running with 32.768 kHz.

Microcontroller sending data to Ds1307 and receiving data from DS1307 via I2C Protocol

What is speed of I2C communication between microcontroller and DS1307 ?
i2c comm speed is something you set but is normally 100kHz or 400kHz. This is well explained and defined in the i2c protocol.

Your clock speed is not the speed you communicate at. No matter what processor/mcu you use (master or slave doesn't matter), the clock it runs at must be faster than anything else it does. That clock is its heartbeat. For sake of example, just imagine that every clock cycle allows your processor/mcu to perform just 1 assembly language instruction. That is basically how all processors work (ignoring pipelining, prefetch, and a host of other things involved to make it much faster).

But using that simple example, your processor must be able to perform several assembly language commands just to do almost anything, therefore its clock must be much faster than whatever else you're trying to do. So, if your PIC is running at 1MHz or 8MHz (typical without external oscillator making it faster), then everything else it does takes some of those cycles- it has to be left with cycles for its own use, for it's own 'housekeeping'. 32.768kHz is extremely slow compared to 1MHz.

1/32768 = 1 cycle about every 30uS
1/1000000 = 1 cycle every 1uS

Hope that helps. One of the things that makes a guru developer is when someone understands how to make each different process or processor work hand-in-hand in different time-bases, without anybody waiting on anyone else.

Now, if you've read the datasheet for the PIC16F877A, and you should have. You can see that within the first few lines, it says the chip can be run at 20MHz using an external oscillator- which is the speed you want to run it at.

1/20000000 = 1 cycle every 50nS

https://www.mouser.com/datasheet/2/268/39582C-278080.pdf
 
Last edited:
Top