Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 11 months ago.
Unable to read or write to watchdog register..
I'm using FRDM-KL46Z freescale microcontroller for the project and wanted to use inbuilt watchdog feature . http://cache.freescale.com/files/microcontrollers/doc/ref_manual/KL46P121M48SF4RM.pdf
But I'm unable to write or read anything from the COP control register (SIM_COPC) (Add:4004_8100 ). Whenever I try reading the register it is always showing 0 whereas its reset value given in datasheet is 0000_000C (pg:202).The following is the code I have used to read from the register and directly print it.
main.cpp
#include<mbed.h> Serial pc(USBTX,USBRX); volatile uint32_t SIM_COPC = *(volatile uint32_t*)0x40048100; int main() { while(1){ pc.printf("%x\n",SIM_COPC); wait_ms(100); } }
This code was giving prooper reset values when I tried with other SIM registers whose reset value was non zero. i.e. it was giving proper reset value which is mentionend in the datasheet. Can somebody plz explain this behaviour of the microcontroller.
1 Answer
8 years, 11 months ago.
Considering by default it is apparantly enabled, and you can only write it once, the source code has only a single option to deal with it: And that is permanently disabling it on startup. Most other watchdogs are by default disabled, so they stay like that and a user can enable it if he wants.
If you want to use it you need to import mbed-src and modify the watchdog setup here: https://developer.mbed.org/users/mbed_official/code/mbed-src/file/a5bce224b5d8/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/system_MKL46Z4.c
Hi, we've imported the library and modified the file.But how to include this library in the code.
posted by 06 Jun 2015
As start, use the built-in register definitions: SIM->COPC should work.
posted by Erik - 06 Jun 2015I have tried that method also but it is still printing 0. I even tried changing the microcontroller, still there is no improvement. As I have mentionend earlier all the other SIM registers are giving proper values except watchdog register (SIM_COPC).
posted by sai kiran 06 Jun 2015