9 years, 4 months ago.

Simple register read not working

I have a FRDM-KL25Z board and I am using the online mbed compiler.

I try to read a register. The register address is printed and seems to match with the address mentioned in the KL25 Sub-Family Reference Manual. ( http://cache.freescale.com/files/32bit/doc/ref_manual/KL25P80M48SF0RM.pdf ) But the register content is not printed. The program seems to crash at the marked line when it is uncommented. What am I doing wrong?

best regards, Ronald

#include "mbed.h"
  
int main() {
    uint32_t x = 1234;
    
    printf( "ADC registers\n" );
    printf( "CFG1        : %p\n", &ADC0->CFG1 );
    //  x = ADC0->CFG1;         // *** uncomment this line **** 
    printf( "CFG1        : %d\n", x );
            
}

I figured it out. When I add 'AnalogIN ain(PTB0);' on line 2 it works. Seems the ADC module has to be configured/powered first. I will look into this...

posted by Ronald Gijsbertse 21 Dec 2014

1 Answer

9 years, 4 months ago.

It is exactly what you write in your comment: unclocked Freescale peripherals result in lock-up when you try to read/write their contents. You always need to make sure the peripheral receives a clock.