2003-06-26 10:27 PM
2003-06-26 02:34 AM
Using the ST7LITE2 ARTimer in PWM mode:
1) Is there any order in writing the DCRxx, ATCSR, ATRxx and PWMCR registers? 2) My program looks like that: PADDR=0x04; // PA2 (PWM0) = output PAOR=0x04; // PA2 = pullup SetBit(ATCSR,FOUR); // Counter Clk = fCPU ClrBit(ATCSR,THREE); ATRH=0x00; ATRL=0x00; DCR0H=0x05; PWMCR=0x01; // PWM0 enable What is wrong with that? There is no signal at the pin which is connected to a LED on the in-DART-STX Demo-board. Do I need the Overflow/Compare interrupts? Are there any examples for ST7Lite2 PWM mode in C? Thanks for any help!2003-06-26 02:48 AM
Hi,
When you write ''DCR0H=0x05;'', the 0x05 are placed into temporaly registers, not in the ''real'' PWM register. By adding TRANCR=0x01 after the DCR0H=0x05 the data is copied into the ''real'' PWM registers. Do not forget to do this later on in your program every time a PWM value has to be changed! Maybe you should place ''PWMCR=0x01'' before the DCR0H=0x05. But i'm not sure. When it still doesn't work i can give a part of code you can use. Just ask. Greets.2003-06-26 03:20 AM
Hello joble
Thank you very much for your help! Indeed, it's important to set the TRAN bit, what i didn't! (With the LITE0, that ARTimer is quite different, unfortunately I have only LITE0 examples). But even with that bit set, it still doesn't work. I tried also to toggle position between the PWMCR and the DCR0H line, but there is still no effect! For the 'DCRxx' lines I disable the interrupts, and enable afterwards, but that doesn't help neither. Do have any other ideas? Thanks again, and have a nice evening!2003-06-26 03:38 AM
This should work, it's copied from a program that works fine. I do not see any difference with your program.
init: PADDR=0x7F; PAOR=0x7F; ATCSR=0x10; ATRH=0x00; ATRL=0x00; PWMCR=0x15; in the program: DCR0H=10; DCR0L=128; TRANCR=0x01; Hope this helps...2003-06-26 07:32 PM
Thank you very much for your help. You thought me about the TRAN bit. Although I have exactly the same program as you, it still doesn't work.
Even with a new uController it is still the same. Maybe there is someone out there from ST interested in helping their costumer? Up to now ST just pointed me to this forum.2003-06-26 10:11 PM
Problem partially resolved!
The PWM function works well on PWM1 but not on PWM0, although they have absolutely the same configuration (Soft-and Hardware)! Anybody an idea why it is so?2003-06-26 10:27 PM
Hi,
Maybe something wrong with the definition of DCR0H and DCROL? Maybe a stupid idea, but i can't find another possible reason. Part of the IO7Flite2.h file: @tiny volatile char DCR0H @0x17; /* PWM 0 Duty Cycle Register High */ @tiny volatile char DCR0L @0x18; /* PWM 0 Duty Cycle Register Low */ @tiny volatile char DCR1H @0x19; /* PWM 0 Duty Cycle Register High */ @tiny volatile char DCR1L @0x1A; /* PWM 0 Duty Cycle Register Low */ @tiny volatile char DCR2H @0x1B; /* PWM 0 Duty Cycle Register High */ @tiny volatile char DCR2L @0x1C; /* PWM 0 Duty Cycle Register Low */ @tiny volatile char DCR3H @0x1D; /* PWM 0 Duty Cycle Register High */ @tiny volatile char DCR3L @0x1E; /* PWM 0 Duty Cycle Register Low Or a hardware fault (try swapping the pins). Greets.