S08MP16 FTM,Stop3 Help

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S08MP16 FTM,Stop3 Help

ソリューションへジャンプ
1,295件の閲覧回数
carlosomarharoc
Contributor II

Hello Dears

 

I'm working with S08 microprocesor

 

I have the next code lines, I'm trying to following the RM but its hard for me.

 

I need use stop mode (stop3) and then wake up via reset.  I'm not sure if the Internal reference clock is 50Mhz or is 25Mhz

Use a PWM at 60Hz for set a intensity to a led

 

#define OVFCOUNT 50 extern unsigned char count = OVFCOUNT; //number of Timer Overflows before increasing the pulse-width   extern unsigned char updown = OVFCOUNT;         //0 for up, 1 for down   void MCU_Init(void)   {   //Crucial (Stop mode configuration)   SOPT1=0x20; //STOPE=1 to SOPT1 register to enable stop instruction   SPMSC1=0x0; //Set to STOP3 without LVD and BDM modes, see table 3.1 on reference manual for more information //SPMSC2=0x1; //Uncomment this line for set to STOP2.   // System Clock Init   ICSC1=0x44;  //Internal reference selected (50Mhz)   ICSC2=0xC0;  // bus clock  to 6.25Mhz (50Mhz/8)    } void configureMTIM(void) {   ////////////////////////////////////////////////////////////////////////////////////   // formula time =((clock divider)*(MTIMMOD register value+1))/BUS clock ///   //////////////////////////////////////////////////////////////////////////////////   MTIMCLK = 0x08;  //  Bus clock (BUSCLK) witch is 6.25Mhz ,  Bus clock 256 divider    MTIMMOD = 0x30; /* Count to 48 ,+1 */   //time 2.007 ms , ((bus clock divider)*(MTIMMOD+1))/busclock "bus clock =6.250mhz" }  void FTM_Init(void) {   //16-bit counter  max:65536 so i cant get a 60Hz in this way    // TPM clock = BUSCLK = 6.25MHz,channel operate in edge-aligned, Overflow Interrupt Enabled   FTM1SC = FTM1SC_CLKSA_MASK | FTM1SC_TOIE_MASK;      //PWM frequency = 60 Hz   FTM1MOD = 375000000;  // TPMclock/TPMxMOD = 6.25MHz/375000000= 60 Hz    // Configure channel 0 to PWM mode (high-true pulses)     FTM1C0SC = FTM1C0SC_ELS0B_MASK | FTM1C0SC_MS0B_MASK;    // Pulse Width   FTM1C0V = 187500000; // PMxMOD/TPMxCnV = 375000000/187500000, channel 0 set to 50% } interrupt VectorNumber_Vftm1ovf void FTM1ovfISR (void) {   // The same problem un FTM_Init cause the 16-bit counter   //Clear interrupt flag   (void)FTM1SC;   FTM1SC_TOF = 0;      count--;   if (!count)   {          if (!updown) //up counting     {       FTM1C0V += 3750000;       if (FTM1C0V == 371250000) updown = 1;       //when reaching 99%, change to down counting     }      else      {       FTM1C0V -= 3750000;       if (FTM1C0V == 3750000) updown = 0;       //when reaching 1%, change to up counting     }              count = OVF_COUNTS;       } }   }

 

 

I really appreciate your time, thanks for the help

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
1,098件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Carlos,

Yes, it hard use the project of PE to no-PE project,  I meaning you can do like this :

According your need create a PE project , it is simple and need little time only configurate the init .

Then refer to the generate code write your own project .

Best Regards

Alice

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,098件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Carlos,

If you not sure how configurate the clock and how to initialize ,you can firstly use the Processor Expert configuration , and there also have "help component "can check the meaning of the related compenet.

  it is convenient . It is configurate like this :

The CPU clock select :

1.png

The FTM clock configuration :

2.png

Best Regards,

Alice

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

If this post answers your question, please click the Correct Answer button.

1,098件の閲覧回数
carlosomarharoc
Contributor II

Hi  dear Alice 

Good answer but... I'm need do the code like a library it will be use in another project, the Microprocesor that I use will be come a slave. In master microprocesor aren't in procesor expert.

I dont know if using procesor expert will works in the project without PEx

0 件の賞賛
返信
1,099件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Carlos,

Yes, it hard use the project of PE to no-PE project,  I meaning you can do like this :

According your need create a PE project , it is simple and need little time only configurate the init .

Then refer to the generate code write your own project .

Best Regards

Alice

0 件の賞賛
返信
1,098件の閲覧回数
carlosomarharoc
Contributor II

Oh   I see

I never thought that way,  thanks  Alice!

Regards.

0 件の賞賛
返信