I have inherited a project that use AT91SAM7A3, IAR EmbeddedWorkbench v4.7.0 and FreeRTOS v4.02.
Eventually managed to get 16 ADC Channels sampling every ms, PWM loading new Duty cycle
appx every 300µs and simultaneously receiving 64 bytes in dbgu UART at 115.2kbps
Essentially two tasks are running, one that calculates average ADC results and one that calculate CRC16 on received bytes and returning ACK if CRC was correct.
I noticed that PWM ISR’s and ADC ISR’s were delayed during the task that calculates CRC, even though PWM was set to highest interrupt priority.
Especially PWM is time critical since it produce AC-wave for motors.
These are the Interrupt and Task priority levels we use:
//rk v3.i FreeRTOS Task priority levels
#define STATUS_PRIORITY (tskIDLE_PRIORITY+1)
#define ADCTEST_PRIORITY (tskIDLE_PRIORITY+4)
#define App1int_PRIORITY (tskIDLE_PRIORITY+2) //this is the task that calculate CRC
#define App1main_PRIORITY (tskIDLE_PRIORITY+1)
//rk v3.i SAM7 Interrupt priority levels
#define ADC_INTERRUPT_LEVEL 4
#define PWM_INTERRUPT_LEVEL 7
#define DBGU_INTERRUPT_LEVEL 3
#define PIT_INTERRUPT_LEVEL 2
Basically I have two questions.
1. Is it at all possible to do nested interrupts with SAM7A3 and FreeRTOS? We’ve tried with no luck so far…
Have read a number of posts on AT91 forum and FreeRTOS forum and concluded that this is not as easy as doing nested interrupts on AVR’s that I’m used to work with.
2. If answer to question #1 is NO, is there some sort of workaround to ensure that PWM (or other time critical code) interrupt the task running (in our case CRC calculation).
Surprised that high interrupt priority IRQ’s such as PWM don’t take precedence over a task that is running (CRC calc). Can a task be interrupted between RTOS ticks?
PWM run at 3200Hz, at the moment RTOS tick is set to 100(10ms). Have seen code with Tick set to 1000(1ms), this would make PWM latency smaller but also slow down general performance.
Have seen advices to similar questions to move most of code inside ISR to a task but as far as I can see this will not work with 3200Hz PWM and 1000Hz RTOS Tick.