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

carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am