Hi...sorry for dealyed response.
Answers below:
On MQXUG I read:
An interrupt comes at periodic intervals that my application must respond to very quickly
— quicker than MQX allows. What can I do? ANSWER: MQX can handle kHz's frequent interrupts but if you want you can do a direct interupt by changing the #define to a 0 rather than 1.
ex: #if 1 //DES 0=direct ISR preempts MQX, 1=kernel isr handles the exception
This assumes your vector table is in RAM.
Call _int_install_kernel_isr() to replace the kernel ISR (_int_kernel_isr()). Your replacement ISR must:
• Save all registers on entry, and restore them on exit. ANSWER: The compiler handles this for you. This note really applies to assembly coded routines.
• It must not call any MQX functions.
• Pass information to other tasks (if required) by an application-implemented mechanism (usually
ring buffers with head and tail pointers and total size fields).
In your example,#if 1 you call _int_install_kernel_isr, therefore I am asuming kernel will handle the interrupt but in the UG I read "Call _int_install_kernel_isr() to replace the kernel ISR". This is confusing, could you explain when to use _int_install_kernel_isr ? ANSWER: Cool feature MQX gives you is that if an interrupt is being used by MQX, MQX lets you use it too. The default example code shows this well as does the modified code. At the beginning of the main_task() function the "old" vector information is added to a isr_ptr structure. Once you place your new ISR handler into the MQX hands, your code wil be called and it is your new ISR codes responsibility to call "old/orginal" isr. This basically creates a linked list of ISRs in this case two deep....your new isr and the old isr.
Then, the UG states that in order to handle an Interrupt outside MQX I must "Save all registers on entry, and restore them on exit". I don't see where is this done in the isr.c example, so is it missing?, is it not necesary to do this? ANSWER: The compiler handles this for you. This note really applies to assembly coded routines.
Finally, I see you are using a global variable in the example (volatile uint_32 bcnt) to pass information from the interrupt to the main task but again, the UG suggest to use "usually ring buffers with head and tail pointers".Can I use just a global variable or should I implement a sofisticated mechanism? ANSWER: Its implementation specific so what works for you is fine. In this case the global works but if I had other tasks accessing that global then not best solution.
Regards,
David