2005-01-10 01:11 AM
2005-01-10 01:11 AM
Hello Everybody i am new here at the forum and also new to the Microthing so maybe its a stupid message...
I need to set up my ST7FLITE29 to work with PWM Output on 250Khz and a Duty Cycle of 50%. But i cant figure out how to initialise it to do so. I dont understand the Datasheet. I read some threads here but didnt figure out either. I calculated the frequency to be ATR value 4080/ 0xFF0 But how do i set the DCR to get 50% and why do i have DRCH and DRCL ???? I am very confused but maybe thats normal at the beginning! I hope there is someone who can explain whats this about and how to get to the 50% Below is my code to initialise. Is it right with the calculation of 4080for 250KHz?? I am running with the internal RC and 8X PLL //initialising I/O ports PADR = 0x1C; //setting up dataregister// PADDR = 0x9F; //setting up datadirection// PAOR = 0xDF; //setting up dataoptions// PBDR = 0xFF; //Setting port B dataregisters// PBDDR = 0x00; //Setting port B Datadirection to input// PBOR = 0x00; //Setting port B to be floating// /******************************************* setting up 12-bit timer for PWM output ***********************************************/ PWMCR = 0x15; //Enabling PWM Output on PWM0, PWM1, PWM2// ATRH = 0x0F; //Autoreloadtimer High// ATRL = 0xF0; //Autoreloadtimer Low// ATCSR |= 0x18; //Set Counter Clk = fCPU// Thank a lot Björn