Created Sun, 26 Aug 2012 23:31:09 +0000 by educa
Sun, 26 Aug 2012 23:31:09 +0000
Hi, I'm new to chipkit but not to arduino or lower level avr programming
Now I try to make a laser cutter controller and need quite high speed for that. The controller will control both stepper motors and a laser power supply
Therefore, I wonder about the following things.
Is it possible to disable ALL interrupts on the chipkit max? I ask this because I expect that like on arduino there is by default an ISR defined which powers the getmillis or getmicros function or whatever. I don't need that function, so I would like to disable all interrupts so my code absolutely doesn't get interrupted. Possible ?
I read that there is a function readcoretimer() which actually gives me the value of a built in 32bit timer with 25ns resolution. I also see that this timer can overflow about every 107 sec, but does this timer work also when interrupts are disabled ? Is this timer read only or can it be zeroed? I would use it to implement some timing without needing interrupts by letting my code wait until the coretimer reaches a certain value. To determine that value I would take the current coretimer and add a certain value to it. I guess the fact that the timer overflows won't hurt me too much for doing this ?
I found online some information about how to do fast pin setting and resetting on chipkit, but can somebody tell me what is the absolutely fastest way to set a whole port? Is it like on arduino with PORTD = B10101000; ?
Bart Libert Belgium
Mon, 27 Aug 2012 09:36:15 +0000
- I found online some information about how to do fast pin setting and resetting on chipkit, but can somebody tell me what is the absolutely fastest way to set a whole port? Is it like on arduino with PORTD = B10101000; ?
Similar. You work with "LAT" registers (latch) for writing, and "PORT" registers for reading. And they're 16 bit registers.
So, to set all of port B to a nice alternating pattern:
Because there are so many IO pins available not all of them are routed to actual physical connectors. Check the manual for your board for a full mapping of all the IO pins.
Wed, 29 Aug 2012 23:14:59 +0000
The noInterrupt() function is a standard Arduino function that turns off the global interrupt enable flag. This disables all interrupts to the processor. The interrupts() function is used to turn on the global interrupt enable flag.
The core timer is part of the MIPS processor. It is in addition to the five 16 bit timers that are part of the set of peripherals. It is a 32 bit counter that increments on every other instruction clock. So, if the processor clock is 80Mhz (which it is for most chipKIT boards), the core timer counter increments at 40Mhz. This happens as long as the processor clock is running. There is also a compare register associated with the core timer that can be used to generate an interrupt when the core timer counter matches the value in the compare register. This interrupt will be disabled when noInterrupts() is used. The core timer and its associated compare register are used to generate a 1ms interrupt that is used to maintain a 32 bit millisecond counter in a global memory variable. This is what is returned by the millis() function.
There is a core timer service facility available that allows a sketch to specify a function to be called when a particular core timer count value occurs. This core timer service facility was added in a test build earlier this summer. It isn't in the last official release, but has been in the last two or three test builds and will be in the next official release. The SoftPWMServo library now uses it.
Gene Apperson Digilent