Go Down

Topic: which processor is faster in 1 mhz inside clock (Read 283 times) previous topic - next topic


I like to know which microcontroller (8051,AVR,PIC,ARM) would run this code in 1mhz inside clock faster?
and why?

(Please explain with full details)

Code: [Select]

int main(void)


   uint8_t i=0;






        PORTx ^=(1<<bit);





Mrs Drew
UK Based PCB Manufacturing - PM for details
I will design & code for you, but I will also charge you (PM me)
Use Google or search this site BEFORE asking!


Jan 24, 2020, 06:35 pm Last Edit: Jan 24, 2020, 06:35 pm by srnet
Indeed, some explanation as to why you need 'full details' would be interesting.

What time did you get for an AVR ?


Well, your code forgets to set the pin OUTPUT...

And you can save I think 2 cycles at least on an AVR by using PINx to lose the read-modify-write cycle:

PINx =(1<<bit);

(oh, and bit isn't declared in your snippet)

I think the difference in number of clock cycles is probably not that large, but you'd have to compile it on each one and see what you get to be sure.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy


i would be tempted to say that the 8051 is the slowest since it used to take 12 Clock cycles per instruction but since there are single cycle variants of the 8051 core around These days (take the at89lp213 for instance) you can not simply say that so simple anymore. thus this Question has to be asked !PROPERLY! first. Including the exact Chips to compare and complete and compilable Code. Also since Compilers for different platforms tend to produce different results (and sometimes not even slightly) there is that influence as well.

Go Up