Created Mon, 10 Mar 2014 09:56:31 +0000 by Kumakiri
Mon, 10 Mar 2014 09:56:31 +0000
Analyzing the oscilloscope, it appears to me that approximately 100us after the trigger, there's an interrupt call. I believe this indicates it's operating at a speed of 10Khz.
I want to work at a speed of 100ns(10Mhz), is there any way to achieve this?
void setup() {
//
pinMode(3, INPUT);
pinMode(28, OUTPUT);
digitalWrite( 28, LOW);
// serial 115200bps.
Serial.begin(115200);
//
attachInterrupt(0, call, FALLING);
}
void loop() {
for(;;){
// DO WORK
}
}
void call() {
digitalWrite(28, HIGH);
{
// DO WORK
}
digitalWrite(28, LOW);
}
Mon, 10 Mar 2014 10:07:16 +0000
attachInterrupt and digitalWrite are relatively slow systems.
If you want to run at 10MHz, which is 1/8th the total clock speed (only time for, like, 8 instructions in an interrupt) you're going to have "fun".
Priority 7 interrupts use the shadow register set. If you don't use priority 7, then all the important registers will need to be saved by the ISR - there's 32 main registers plus some extra co-processor registers. In total you need to save (IIRC) 32 registers as some are "temporary" and don't need saving. That's 32 instructions (and 32 clock cycles) just to do the saving of the registers (not counting the setting up of the stack frame to store them all).
The digitalWrite() function is slow. It looks up pin to port mappings on the fly, checks for disabling of things like PWM on the pin, etc. All in all it goes slow. You really need to directly manipulate the LAT registers to get any semblance of speed out of it.
Maybe there's another way of doing what you want? What are you trying to achieve with the interrupt? Could it be done using a timer, or input compare?
Mon, 10 Mar 2014 14:04:19 +0000
majenko is being nice. There is a very, very small chance that you'll get an interrupt to run at 10MHz on this part. If your entire ISR was only 8 instructions long, you would be using 100% of the CPU just for your ISR. And an 8 instruction ISR is nearly impossible - since it must also do some real work besides getting into and out of the ISR.
My suggestion is to re-design your system architecture so that you don't need to run an ISR this fast. Is there another way to accomplish the same goal you're trying to achieve?
*Brian
Wed, 12 Mar 2014 20:43:26 +0000
.. and when o'clocking @120MHz? That will allow 12 instructions.. :)
Thu, 13 Mar 2014 14:26:53 +0000
Oh, duh. Yeah, of course. If you overclock the part, you should have no problem.
<grin>
But seriously, when the MZ series of chipKIT boards come out (soon), running at 200Mhz, this will be a much more realistic goal.
*Brian
Thu, 13 Mar 2014 14:33:35 +0000
Oh, duh. Yeah, of course. If you overclock the part, you should have no problem. <grin> But seriously, when the MZ series of chipKIT boards come out (soon), running at 200Mhz, this will be a much more realistic goal. *Brian
Define soon? I heard they were due for release last autumn... and still no sign of them...
Thu, 13 Mar 2014 17:51:02 +0000
Yeah, of course. If you overclock the part, you should have no problem.
What about the 470F512H(L) parts - I've got the parts, but not tested them yet. They may overclock 160MHz, maybe more..
Thu, 13 Mar 2014 19:10:16 +0000
Define soon? I heard they were due for release last autumn... and still no sign of them...
Actually, PIC32MZ Starter Kits have been shipping since November:
http://www.microchipdirect.com/ProductSearch.aspx?Keywords=DM320006
However, you are correct in that the chips themselves have not been released to production. My understanding is, that will happen later this month (March 2014).