(MC68HC908JK1) TIM module configuration Question

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

(MC68HC908JK1) TIM module configuration Question

1,381 Views
mauricio2346
Contributor II
hi!
i need some help with the configuration of this module (TIM) on the MC68HC908JK1 microcontroller

with a crystal of 4.9152 Mhz i need a PWM signal of this characteristics:

40Khz frecuency
10% of Duty (high time)

maybe this could be the code:

void Init_PWM(void){
    TSC  = 0x30;  
    TMOD = 123;                       
    TCH0 = 12; 
    TSC0 = 0x1A;                   
    TSC  = 0x00;                
}

i'm all right???

please help me

greetings...
Labels (1)
0 Kudos
3 Replies

274 Views
fjrg76
Contributor IV
Hi!!

Some time ago I wrote notes on using some HC(S)08 features in order to use them later on, including PWM generation, however, those notes are written in spanish, so if you know a little bit of my language then my example may help you a lot. Please take a look at

http://mx.geocities.com/fjrg76/HC08_pwm.htm

If you don't understand don't worry there are code that you may try. Good luck and regards =)
0 Kudos

274 Views
mauricio2346
Contributor II
Hi!
ok, i will make those changes to the code.   in this moment i'm using another code to control this module.   maybe in the next two days i'll improve my own.
thanks!

fjrg76,  muchisimas gracias por la información.  es bastante util.  pregunto ya que hace mas o menos unos 4 años me mostraron el codigo alargado para controlar el modulo TIM, y he tratado de hacerlo mas simple, de manera que funcione mejor, pero como no he practicado mucho, se me han olvidado algunas cosas. Saludos
0 Kudos

274 Views
bigmac
Specialist III
Hello,
 
There seems to be a couple of issues with your code.  Firstly you have not taken into account that the bus frequency will be one quarter the crystal frequency.  The PWM frequency will therefore be (4915.2/ 4/(123 +1)) ~= 9.91 kHz.  The duty cycle will be (12/(123 + 1) * 100) ~= 9.7 percent.
 
The other issue is that the TSC setting is incorrect - you are stopping the TIM module.
 
Regards,
Mac
 
0 Kudos