Discussion in "8051 Discussion Forum" started by    bobster    Nov 6, 2015.
Fri Nov 06 2015, 12:09 am
#1
Hi all,

I am using an atmel 89c5131 microcontroller with a 24mhz crystal running with X2 enabled (system clock only, not peripheral clock).

I have an external source generating a square wave which is fed into an external interrupt. The external int has highest priority and there is another timer (60 millisec) which has a lower priority. Its configured to vector on the falling edge.

The idea being the external interrupt fires and increments a counter each interrupt. The 60msec timer interrupt then fires, reads the counter and resets it. Then the process starts again.

The external frequency can range from 1khz to 800khz.

It all works fine up until the external interrupt frequency reaches 500khz. It then hangs the processor and it stops firing the timer interrupt.

If i disable X2 mode on the 24mhz crystal then i can only go to 250khz on the external interrupt.

if i fit a 48mhz crystal (and have to disable X2) then the timer interrupts run faster (i wasn't running those in X2 mode with the 24mhz), but when the external frequency reaches 500khz it hangs again.

if the max speed that the external int can process interrupts is 1/24 crystal speed then this would give a max of 1mhz with a 24mhz crystal, but i am seeing 500khz.

Google results seem to be saying that 500khz is the limit for a 12mhz crystal so i cant work out why i am seeing this limitation with 24mhz. I need to be able to process up to about 800khz external interrupt speeds.

thanks in advance for any help, its driving me mad!
Fri Nov 06 2015, 06:42 am
#2
The key thing is the length of the interrupt code.

As I see it, you can process 4 million instruction cycles per second
using a 24MHz crystal.
At 500KHz that's only 8 cycles, including interrupt overheads,
You can't do much with that !

Check your compiler listings, see what code is being generated
and add up the instruction cycles.
Note that there may be more than one instruction cycle per instruction.
Basically there is not enough time for code to complete.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm
Robertgurse
Wed Apr 24 2024, 02:43 pm
Richardedils
Wed Apr 24 2024, 04:07 am
ChrisLub
Tue Apr 23 2024, 05:21 pm
Davidbab
Tue Apr 23 2024, 10:41 am
Richardrit
Tue Apr 23 2024, 09:54 am
HenryLaf
Mon Apr 22 2024, 03:50 pm