Dear Sir. or Mandam,
I have some problem in the the configuration of counter prescale of MPC5748G, STM module, attached is my project and the serial debugging assistant that will be used in my project.
In my project, STM_0 is enabled. STM_0.CNT.R increments at the frequency of the system clock, the compare value is set to 0x77359400. When STM_0.CNT.R matches the compare value, an interrupt will be inserted and LED1 will be turned on, "the channel compare register matches the timer counter" will be displayed in the serial debugging assistant.
However, if you step into STM_Init(&STM_0,&sSTMConfig1) in main.c,
then uncomment the "STM_Counter_Prescaler(pSTM, (config->counter).CounterPrescaler);" which set the devide value for the prescaler,
then the program will stop at this line while debugging.
Original Attachment has been moved to: mpc5748g_Z4_1.rar
Could you please help me to find out what's wrong it is? Thank you very much!
Hi,
you must not use bit access to write to STM registers.
You have to use pSTM->CR.R = 0x00000101; instead of pSTM->CR.B.CPS=to_set;
Regards,
Martin