Hi David,
I started with the TWRK40D100 as recommended by Mr Martin Latal in response to this question here: https://community.freescale.com/thread/307573. The major difference between the K40 derivative in the TWR and the K20 we use is the K40 incorporates one LCD controller. I simply removed the sources (links in the project) and all references in the rest of the source files (initialization, configuration, etc).
Another major difference I found later was the flash configuration, the K40 has flash and flex memories, the K20 has only flash, and larger in size.
I posted this question here (https://community.freescale.com/thread/312312) with several questions, one of them is about how to solve this memory missmatch.
After testing several methods using the MQX hwtimer drivers I came up with a working solution for this timing/timer usage scenario but it was too late and I did not post it here. I ended up using one PIT and modifying the PIT hwtimer driver for adding one new function. The method I used was very simple:
- Configure the timer with a very low frequency so the tick interrupts occur long after all the process has completed (after the trigger event, at most 10ms lapse until the last timed operation is completed),
- Start the timer when the event is fired.
- Precalculate the thresshold for the PIT counter,
- Keep reading the PIT downcounter until the thresshold value is passed and end the wait.
Major problem I found with this approach was the massive overhead imposed by the driver design, the best resolution I was able to achieve with the mqx hwtimer driver functions was worst than 2.5us (with the CPU running at 96MHz), and I needed it be equal or better than 1/2us. At the end I added this function in the hwtimer_pit.c file (see below) that partly solved the timing problem:
void hwtimer_pit_wait_count(HWTIMER_PTR hwtimer, uint_32 Count ) {
PIT_MemMapPtr pit_base = (PIT_MemMapPtr) hwtimer->ll_context[0];
uint_32 pit_channel = GET_PIT_CHANNEL_FROM_PITID(hwtimer->ll_context[1]);
Count = PIT_LDVAL_REG(pit_base, pit_channel) - Count;
while (Count < PIT_CVAL_REG(pit_base, pit_channel))
{}
}
Due to severely restricted timing constraints I can not use the classic RTOS Flag/Semafore/Mutex design pattern for this part of the application.
I will take a close look to the TWR-K60D100M, thanks for mentioning it.
Could you, please, take a look at the pending questions in the above mentioned forum posts?
Best regards,
Victor