Hi Alex
I hadn't tried this but it was the only method that I could think of that would be easy to recover from if the access failed.
This is the code that I suggest:
{
unsigned long ulRegCopy;
POWER_UP_ATOMIC(6, RTC); // ensure the RTC is powered
if (DMA_ERROR_OCCURRED == fnConfigDMA_buffer(4, 0, sizeof(ulRegCopy), (void *)RTC_BLOCK, &ulRegCopy, (DMA_DIRECTION_INPUT | DMA_LONG_WORDS | DMA_SINGLE_CYCLE | DMA_FIXED_ADDRESSES | DMA_SW_TRIGGER_WAIT_TERMINATION), 0, 0)) { // configure the transfer, start and wait for termination
// RTC cannot be accessed - probably due to missing VBAT voltage
//
}
else {
// ulRegCopy has the present RTC_TSR content, meaning that the RTC could be accessed
}
}
This is using DMA channel 4 for the test (the channel used being configurable).
I have however just added a return value to fnConfigDMA_buffer() as well as a check for DMA errors during the copy. You can get the updated kinetis.h (with prototype) and kinetis_DMA.h from the repository (I just checked them in).
Tell me whether the solution works for your requirements.
Good luck
Regards
Mark
P.S. Could you give me a link to the NXP forum post since I couldn't find it when I just searched?