1
NXPTM M522XX, KINETIS and i.MX RT / uTaskerSerialBoot Teensy 3.x ADC access troubles
« on: July 25, 2018, 03:24:10 AM »
Hey Mark / Guys,
I am having an issue implementing ADC access in the Serial Bootloader....
I am using a slightly modified version of the uTaskerSerialBoot Application in KDS and I think something is going on that i might be simply overlooking.
I didn't see an easy way to access ADC channels so I attempted to initialize and read the hardware registers directly but I am running into resets when finishing the calibration routine or seemingly accessing any hardware addresses directly.
//----.h header-----
#define ADC0_CFG1 (*(volatile uint32_t *)0x4003B008)
#define ADC0_CFG2 (*(volatile uint32_t *)0x4003B00C)
#define ADC0_SC2 (*(volatile uint32_t *)0x4003B020)
#define ADC0_SC3 (*(volatile uint32_t *)0x4003B024)
#define ADC_SC3_CAL ((uint32_t)0x80)
//---- I call this function first without problems
//----.c code-----
void analog_init(void)
{
ADC0_CFG1 = (uint32_t)0x7B;
ADC0_CFG2 = (uint32_t)0x48;
ADC0_SC2 = (uint32_t)0;
ADC0_SC3 = (uint32_t)0x87;
}
//---- Then I call the following
void wait_cal(void)
{
int attemptscnt = 0;
while (ADC0_SC3 & ADC_SC3_CAL) {
attemptscnt += 1;
}
}
The code fails and the board resets as soon as i try to read ADC0_SC3..
thinking i might be waiting too long and inadvertently triggering a watchdog reset I changed
while (ADC0_SC3 & ADC_SC3_CAL) {
to
if (ADC0_SC3 & ADC_SC3_CAL) {
but the behavior continues...
It looks like the Kinetis_ADC stuff is all #ifdef out but I could be missing something that is causing a conflict
can you think of anything that might cause this or maybe have some things i could check for?
any help is greatly appreciated.
I am having an issue implementing ADC access in the Serial Bootloader....
I am using a slightly modified version of the uTaskerSerialBoot Application in KDS and I think something is going on that i might be simply overlooking.
I didn't see an easy way to access ADC channels so I attempted to initialize and read the hardware registers directly but I am running into resets when finishing the calibration routine or seemingly accessing any hardware addresses directly.
//----.h header-----
#define ADC0_CFG1 (*(volatile uint32_t *)0x4003B008)
#define ADC0_CFG2 (*(volatile uint32_t *)0x4003B00C)
#define ADC0_SC2 (*(volatile uint32_t *)0x4003B020)
#define ADC0_SC3 (*(volatile uint32_t *)0x4003B024)
#define ADC_SC3_CAL ((uint32_t)0x80)
//---- I call this function first without problems
//----.c code-----
void analog_init(void)
{
ADC0_CFG1 = (uint32_t)0x7B;
ADC0_CFG2 = (uint32_t)0x48;
ADC0_SC2 = (uint32_t)0;
ADC0_SC3 = (uint32_t)0x87;
}
//---- Then I call the following
void wait_cal(void)
{
int attemptscnt = 0;
while (ADC0_SC3 & ADC_SC3_CAL) {
attemptscnt += 1;
}
}
The code fails and the board resets as soon as i try to read ADC0_SC3..
thinking i might be waiting too long and inadvertently triggering a watchdog reset I changed
while (ADC0_SC3 & ADC_SC3_CAL) {
to
if (ADC0_SC3 & ADC_SC3_CAL) {
but the behavior continues...
It looks like the Kinetis_ADC stuff is all #ifdef out but I could be missing something that is causing a conflict
can you think of anything that might cause this or maybe have some things i could check for?
any help is greatly appreciated.