PWM question for HCS08 series

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

PWM question for HCS08 series

Jump to solution
1,273 Views
BogieBen
Contributor I

We are using the HCS08 series 8 bit micro's in our two different project.

Our first project used the MC9S08GQ8.
We created an output clock toggling on PB5 and it worked fine.
Below is the C section for this.


 PTBD_PTBD1 =1;    // Port B/1 is POWER LED  0 = on
 PTBDD_PTBDD1 = 1; // Set PTB1 as an output

 PTBD_PTBD2 =0;    // Port B/2 is -RESETDSP   0 = -DSP IN RESET
 PTBDD_PTBDD2 = 1; // Set PTB2 as an output  put dsp into reset

 PTBD_PTBD3 =1;    // Port B/3 is -DSPPDN    1 = POWER ON
 PTBDD_PTBDD3 = 1; // Set PTB3 as an output

 PTBD_PTBD4 =1;    // Port B/4 is -ENCLASSD SET OFF 0= AMP ON
 PTBDD_PTBDD4 = 1; // Set PTB6 as an output




   // MAX count = (PWM count * 2) - 1 for 50% duty
 TPMMODH = 0;      // Channel 1 Max count  (HIGH)
 TPMMODL = 67 ;    // ""(TPMC1VL *2)-1=50% (LOW)
 TPMC1VH = 0;      // Channel 1 PWM count  (HIGH)
 TPMC1VL = 34;     // ""   26                (LOW)
 TPMC1SC = 0x28;   // Channel 1 Edge-aligned, High-true
 TPMSC = 0x08;     // !Center-aligned, use BUS-clock, divide by 1



Now for our new project we are using the MC9S08SL8.
We try and toggle the same PB5 bit and you can see the pin initialize
however we cannot get an output clock to form.
Below is the C code used.
Is there a power down register that we have to enable or a turn clock
signal on that we cannot find in the datasheet here.
Any input would be greatly appreciated.



 PTCD_PTCD3 =1;    // Port B/1 is POWER LED  0 = on
 PTCDD_PTCDD3 = 1; // Set PTB1 as an output

 PTBD_PTBD2 =0;    // Port B/2 is -RESETDSP   0 = -DSP IN RESET
 PTBDD_PTBDD2 = 1; // Set PTB2 as an output  put dsp into reset

 PTBD_PTBD3 =1;    // Port B/3 is -DSPPDN    1 = POWER ON
 PTBDD_PTBDD3 = 1; // Set PTB3 as an output

 PTBD_PTBD4 =1;    // Port B/4 is -ENCLASSD SET OFF 0= AMP ON
 PTBDD_PTBDD4 = 1; // Set PTB6 as an output

 //PTBD_PTBD5 =1;    // Port B/5
 //PTBDD_PTBDD5 = 1; // Set PTB5 OUTPUT



   // MAX count = (PWM count * 2) - 1 for 50% duty
 TPM1MODH = 0;      // Channel 1 Max count  (HIGH)
 TPM1MODL = 135 ;    // ""(TPMC1VL *2)-1=50% (LOW)
 TPM1C1VH = 0;      // Channel 1 PWM count  (HIGH)
 TPM1C1VL = 68;     // ""   26                (LOW)
 TPM1C1SC = 0x28;   // Channel 1 Edge-aligned, High-true OK
 TPM1SC = 0x08;     // BUS-clock ,divide by 1


Thanks,

Labels (1)
0 Kudos
1 Solution
449 Views
ThaManJD
Contributor III

I'll assume you mean the one that works is an S08QG8.

 

I wonder if this is a difference between TPM v2 and TPM v3.

QG8 is a V2 TPM

The SL8 reference manual TPM chapter heading says the timer is V2 but then talks about the differences between V2 and V3 at the end of the chapter.

 

V3 has a difference in the latching mechanisms for the joined bytes of channel and modulo registers. I wonder if it has anything to do with this?

 

 In your SL8 code, I wonder if the "coherency" mechanism is being reset by writing the status and control register right after writing the channel registers.

 

In the notes for the V3 TPM, they suggest that maybe you should write the channel registers and then read them in a while loop comparing them to the expected values until the compare read proves they've been updated. Then you could write your Status and Control registers.

 

JD

 

View solution in original post

0 Kudos
2 Replies
450 Views
ThaManJD
Contributor III

I'll assume you mean the one that works is an S08QG8.

 

I wonder if this is a difference between TPM v2 and TPM v3.

QG8 is a V2 TPM

The SL8 reference manual TPM chapter heading says the timer is V2 but then talks about the differences between V2 and V3 at the end of the chapter.

 

V3 has a difference in the latching mechanisms for the joined bytes of channel and modulo registers. I wonder if it has anything to do with this?

 

 In your SL8 code, I wonder if the "coherency" mechanism is being reset by writing the status and control register right after writing the channel registers.

 

In the notes for the V3 TPM, they suggest that maybe you should write the channel registers and then read them in a while loop comparing them to the expected values until the compare read proves they've been updated. Then you could write your Status and Control registers.

 

JD

 

0 Kudos
449 Views
BogieBen
Contributor I

JD,

That was it .... thank you very much for the point in the right direction.

Cheers,

Ben

0 Kudos