MCF51AC256A TPM3 interrupt problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF51AC256A TPM3 interrupt problem

Jump to solution
1,131 Views
mladenkoren
Contributor I

Hello,

I'm trying to setup TPM3CH0 timer to get every 150ms interrupt to execute one function, using CodeWarrior Development Studio for Microcontrollers V6.3. I did not use Processor Expert or Device Initialization because I'm changing old code and adding some new stuffs. On PTB0 (TPM3CH0) is connected LED.

 

Below is c/p part of code responsible for TPM3

 

 

   

   void main (void)

     { 

          /*cut*/      

            //TPM3MOD=19660 ;  //150ms

            TPM3MOD=58980;          //450ms to see if led blink

            TPM3SC_PS=5 ;    //PS=5 -> =Tclock*32

            TPM3SC_CLKSx=1;  // Clock is bus clock(=fosc/2)

            TPM3C0SC_MS0x=1;  //mode out

            TPM3C0SC_ELS0x=1; //toggle output

 

            TPM3SC_TOIE=1;

            EnableInterrupts; /* enable interrupts */

 

           /*cut*/

 

     }

 

void interrupt VectorNumber_Vtpm3ch0 tpm3ch0_isr(void) {

  TPM3C0SC_CH0F=0;

  //TPM3C0V=19660;

  TPM3C0V=58980;     //450ms to see if led blinking

   FunctionCall();          //call my function

}

 

But when first time TPM3C0V reach value of 19660, it True-Time Simulator & Real-Time Debugger, in Command window I got "ILLEGAL_BP". I try put breakpoint at first line in interrupt but program never reach that part.

 

Can someone, please, help me to debug code (I'm new in CW & MCF51).

 

Thanks and regards,

Mladen

Labels (1)
0 Kudos
1 Solution
958 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Mladen,

I just tested your code on my 51ac256a board, there is no error. see attached demo project and video.

can this help you?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

6 Replies
958 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

In your code, it seems you didn't enable channel 0?

TPM3C0SC_CH0IE=1


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
958 Views
mladenkoren
Contributor I

Hi,

I add now TPM3C0SC_CH0IE=1, but problem is same. When TPM3CNT==TPM3MOD, debugger write ILLEGAL_BP in command window and stop MCU. After that value of both registers are 0.

Best regards,

Mladen

0 Kudos
959 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Mladen,

I just tested your code on my 51ac256a board, there is no error. see attached demo project and video.

can this help you?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

958 Views
mladenkoren
Contributor I

Hi Jennie,

When I load only this code it's working. I have HMI display on serial port, which using DF4 protocol. When I load code for display, then I get illegal_bp. Seems that it's problem if interrupt occurs in subroutine for display.

Thanks for help and best regards,

  Mladen

0 Kudos
958 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Mladen

It looks like the MCU is getting lost when the interrupt occurs. Please first verify that the interrupt routines associated with the interrupt are located at the correct place. Verify that your interrupt vectors do point to the appropriate interrupt routine. 

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
958 Views
mladenkoren
Contributor I

Hi,

I try with associate interrupt routines with:

void interrupt VectorNumber_Vtpm3ch0 tpm3ch0_isr(void) {

interrupt VectorNumber_Vtpm3ch0 void tpm3ch0_isr(void) {

void interrupt 92 timer () {

And I notice that when I get ILLEGAL_BP that TPM3MOD got 0 value (while code is running TPM3MOD is 19660 or 58980 when I change to test on LED).

Regards,

Mladen

0 Kudos