Problem with code for KL25Z32VFM4 PWM and wake up timer

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

Problem with code for KL25Z32VFM4 PWM and wake up timer

702 Views
Embionics
Contributor III

Hello All,

 

I am working with code worrier 10.3.

I have created code using processor expert.

In my code there are 3 configuration settings

Config 0- PEE mode (External Crystal)

Config 1 –FEE mode (Internal crystal)

Config 2 – BLPI mode (Internal crystal)

 

But I have written code for PWM, Wake up timer by myself (from reference of processor expert generated code for PWM and wake up timer)

 

I am using Wake up timer to wake up from LLS mode.

Also PWM to generate pulses at PTB0 pin

 

All above setting I have done for FRDM KL25Z128VLK4 Controller.

And it’s working Fine. I can wake up from LLS mode and Pulses are there at PTB0 pin.

 

Now I want to use KL25Z32VFM4. I have made all above same setting for this controller.

I have checked LED blinking, UART and Timer 2 (Code is same as that of KL25Z128VLK4) with this controller. Its working.

 

Before building the program need to update” vector.c” as

1)Need to add hex file of LPTMR interrupt and need to call TMR_IRQ_handler  from Vector table.

 

  1. But Code for PWM at pin PTB0 And wake up timer To wake up from LLS mode is Not working with this KL25Z32VFM4.

 

I have attached both the codes.

“Test_Code_KL25Z80pin” – Code for KL25Z128VLK4 –its working.

“Test_Code_KL25Z80pin” – Code for KL25Z32VFM4 – its not working.

 

  1. In code for KL25Z32VFM4 before executing main application of mine it is going into hard Fault.

It is going into hard fault at the definition of PORT D pin  PTD 4 which I am using as a LLWU pin to wake up from Low power mode.

To overcome out off this I added a line in “ CPU.c “ file as

SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK; before PTD4 mux setting in “ PE_low_level_init” function.

And it is working I am not getting why there is a problem as Same setting works fine for KL25Z128 controller.

 

Please help me in these 2 questions guide me where I am getting wrong.

 

regards,

Amreen

Original Attachment has been moved to: Test_Code_KL25Z32pin.rar

Original Attachment has been moved to: Test_Code_KL25Z80pin.rar

Labels (1)
0 Kudos
Reply
2 Replies

480 Views
adriancano
NXP Employee
NXP Employee

Hi,

I am checking the code of both project and I found some difference that probably are causing what you reporting. Check the image below the code shown in the left side correspond to the 32pin and in the right to the 80pin.

CPUc difference.png

  • In the LLWU Module Enable register (LLWU_ME) the field WUME0:

          LLWU_ME &= ~LLWU_ME_WUME0_MASK this is WUME0 = 0

          if

          WUME0 = 0 --> Internal module flag not used as wakeup source

          WUME0 = 1 --> Internal module flag used as wakeup source

  • In the Power Mode Protection register (SMC_PMPROT) the field AVLLS

          by default the value is 0

          if

          AVLLS = 0 --> Any VLLSx mode is not allowed

          AVLLS = 1 -->Any VLLSx mode is allowed

The with the values in the 32pin code VLLSx modes are not allowed and another module's flag cannot be the wakeup source. You need to change this register in the component inspector of the CPU: click on the component CPU:MKL25Z32VFM4>click Advanced in the upper right corner> got to the values the image below shows> Enable Very Low Leakage stop mode > enable internal module 0 (LPTMR0) > Create processor expert code > Compile project

component inspector enable wakeup.png

I hope this information can help you.

Regards,

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

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

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

0 Kudos
Reply

480 Views
Embionics
Contributor III

Hello Adrian Sanchez Cano ,


Thanks for your reply.

I haven't enable my LPTMR in CPU setting that is the reason my wake up timer was not working.

I tried wake up timer without going into LLS mode and it is working.

But when i enable timer and call "Cpu_SetOperationMode(DOM_STOP, NULL, NULL);"  for entring into LLS mode.

My wake up timer is not working.

Also i am not getting reason why my PWM is not working it is not related to low power mode.

Amreen

0 Kudos
Reply