PWM Setup Issue I Can't get the TPMCH1 to work

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PWM Setup Issue I Can't get the TPMCH1 to work

2,919 次查看
vatothree
Contributor I
I am Using a MC9S08QG8 and I have been trying to figure out how to use PWM on the TPMCH1 for ever and I can't seem to figure it out. I have successfully configured the TPMCH0 to work and I have tested it both with the True - Time Simulator and buy hooking up Port A pin 0 to an H-Bridge and Watching as my motor turns.

Here is the initialization code that i am using.

void MCU_init(void) {
SOPT1 = 0x00;
TPMMOD = 0x00FF;
TPMC0V = 0x0049;
TPMC1V = 0x00A7;
TPMC0SC = 0b00111000;
TPMC1SC = 0b00111000;
TPMSC = 0b00010000;
PTADD = 0xff;
PTBDD = 0xff;
PTAD = 0x00;
PTBD = 0x80;
}

and after the MCU_init(); function runs there is a infinite for loop.

Does anyone know what the problem is
标签 (1)
0 项奖励
回复
5 回复数

1,415 次查看
vatothree
Contributor I
Well no matter which set up I use for instance if I just use the code as following


void MCU_init(void) {
SOPT1 = 0x00;
TPMMOD = 0x00FF;

TPMC1V = 0x00A7;

TPMC1SC = 0b00111000;
TPMSC = 0b00010000;
PTADD = 0xff;
PTBDD = 0xff;
PTAD = 0x00;
PTBD = 0x80;
}

Then when I check the True - Time Simulator The output of the TPMCH0 will change to hex 01 or just 1. I believed that if I was using the TPMCH1 then it would cause the TPMCH1 PortB pin 5 would go high just as TPMCH0 PortA pin 0 goes high all the time.
0 项奖励
回复

1,415 次查看
thisobj
Contributor III
In your 2nd test:

TPMCH1/PTB5 is programmed to be a PWM output.
The waveform will be (approx) 66% duty cycle - high true.
Since it is programmed as a PWM, the bits written to port B will not affect the PTB5 output.

TPMCH0/PTA0 is programmed as an output (no PWM).
The PTA0 output will go low (0) and will remain low because you have written 0's to the port.

Are you testing this with the debugger on the DEMO9S08QG8 board?
I have loaded both of your programs onto the demo board, 'scoped the output pins, and they work as programmed in each case.

What are you trying to accomplish with the outputs?

Frank
0 项奖励
回复

1,415 次查看
vatothree
Contributor I
Frank

My problem was actually just a problem with the True - Time Simulator. It does not actually show the PWM on Port B pin 5 changing in the simulation buy I hooked up the circuit up to an LED and it worked thank you for helping me.

Ezra
0 项奖励
回复

1,415 次查看
joerg
Contributor II
Dear Ezra
be careful with simulation of the TIM units! There seems to be a bug in the interrupt interface. I have this kind problems since CW3.1 with HCS08 devices. As far i know PE will fix this in CW5.2 coming soon.

Saluti Joerg
0 项奖励
回复

1,415 次查看
thisobj
Contributor III
What is the output doing (or not doing) that indicates to you that it is not working?
Have you monitored the output pin with a voltmeter or a 'scope?
I don't see anything wrong with your register setup.

Frank
0 项奖励
回复