Hi,
Working with Tiva evaluation board DK-TM4C123G and TiRTOS with Bluetooth module CC2564.
The board is up and running bluetooth is working and UART is working as well.
We tried to set a timer for the application. And calling to Timer_create caused system exception. Not right away when timer is enabled, but after a while when another task using the UART was working.
We have found that the Timer)create call is disabling the clock for UART0 and UART1. The next time system is trying to access the UART - there is an exception.
Digging further we found that on the TIRTOS the time enable code is using the function Timer_enableTiva below, on the marked line - the UART clock is diabled.
Void Timer_enableTiva(Int id)
{
UInt key;
key = Hwi_disable();
/* if a pre-Flurry class device, and one of the first four timers ... */
if (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_CLASS_M) <
SYSCTL_DID0_CLASS_FLURRY) && (id < 4)) {
/* enable run mode clock */
*RCGC1 |= (UInt32)(1 << (id + 16)); <-------------------------------------------------------------Clock shut down here
/* ensure at least 5 clock cycle delay for clock enable */
*RCGC1;
*RCGC1;
*RCGC1;
*RCGC1;
*RCGC1;
/* do a sw reset on the timer */
*SRCR1 |= (UInt32)(1 << (id + 16));
*SRCR1 &= ~(UInt32)(1 << (id + 16));
}
/* else, Flurry or later device, or 5th timer or above ... */
else {
/* enable run mode clock */
*RCGCTIMERS |= (UInt32)(1 << id);
*SCGCTIMERS |= (UInt32)(1 << id);
*DCGCTIMERS |= (UInt32)(1 << id);
/* ensure at least 5 clock cycle delay for clock enable */
*RCGCTIMERS;
*RCGCTIMERS;
*RCGCTIMERS;
*RCGCTIMERS;
*RCGCTIMERS;
/* do a sw reset on the timer */
*SRTIMER |= (UInt32)(1 << id);
*SRTIMER &= ~(UInt32)(1 << id);
}
Hwi_restore(key);
}
According to the documentation this register is legacy mode and it is Read Only register (but the code is writing to it.
The "new" code is using direct address to enable each module clock. We can see that when writing to the legacy register - the "new" register is changing as well.
But - when writing to the new register - the legacy one does not update.
So part of the code is using the new registers to enable the peripherals. The time code is using read-modify-write on the legacy one but wile doing that it is changing the other modules state.
Temporary fix was done by changing the other modules enable code in the driverlib to use the legacy register. This was done since changing the tirtos code seems much more complex and dangerous for us.
But - this will be a problem later since every time we might fall for the same issue with other modules.
1. What is the right solution?
2. Is this a known bug? and if not - it should be?
3. If we go with fixing the fnction at the tirtos - is it enough to change this file in the code or does it already exists in a compiled library?
Thanks,
Doron