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.

ATMEGA328P and it's speed

Status
Not open for further replies.

Kittu20

Member level 2
Joined
Oct 18, 2022
Messages
52
Helped
1
Reputation
2
Reaction score
0
Trophy points
6
Activity points
427
The ATMEGA328P can only run at 20 MHz at its fastest.

How can we roughly find out how long the ATMEGA328P microcontroller is taking to set or reset a pin?

roughly how long the ATMEGA328P microcontroller is taking to transfer one bit to PC via Uart for Typical 9600,N,8,1?
 

Hi,

There is a command list (Instruction Set) in each datasheet that tells you how many clock cycles each command takes.
Most commands take just one clock cycle, thus 50ns @ 20MHz.

UART: this is not a microcontroller problem. Echa microcontroller has to do this at the given speed.
You say 9600, N, 8, 1. But ask for one bit. (N, 8, 1 ... does not matter) one bit will be 1/9600 s = 104us
...
The microcontroller just needs one command to put a whole byte (=8 bits) to the UART TX register.
I guess 2 clock cycles (100ns) .. but read the command list.
For transferring 1 byte with N,8,1 you need to transfer 10 bits (START + 8 data + STOP) --> 1.04ms
...

So transferring many bytes to the UART this means:
* 100ns for transferring the byte to the UDR
* wait 1.04ms
.. then transfer the next byte.

Many newbies do this with a "busy wait" between bytes. Consuming 100% of processing power.
More advanced is to use a software_UART_buffer and feed the UDR interrupt controlled.

The interrupt handling maybe just takes 1% of processing power, so you still have 99% of processing power available for doing the main job.

Klaus
 
PIC vs Atmega328 :

1675548372902.png




Regards, Dana.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top