cancel
Showing results for 
Search instead for 
Did you mean: 

ST&litte05 PWM problem

terryhao
Associate II
Posted on December 03, 2002 at 10:25

ST&litte05 PWM problem

2 REPLIES 2
terryhao
Associate II
Posted on December 03, 2002 at 04:16

Dear All,

I am new of ST MCU. Now I use the ST7 visual debug simulator to implement a PWM funciton on ST7Lite But I found there was some problem. I can not look at the wave form in ST7 wave form editor. could anyone help me?

the part source code are as bellows:

main

call init ; port initialization

call init_pwm

.loop jra loop

.init

ld A, $1F

ld PADDR, A ; configures port A[0..4] as output

ld PAOR, A

ld A, $07

ld PBDDR, A ; configures port B[0..2] as output

ld PBOR, A

ld A, $23 ; enables the A/D peripheral on PB3

ld ADCCSR, A

ret

.init_pwm

ld A,0 ; 0 0 0 0 0 0 OP0 CMPF0

ld PWM0CSR,A ; bit 1 set the PWM invert or noinvert

ld A,8

ld ATRH

ld A,0

ld ATRL,A ;set ART, ie. set the PWM frequency

ld A,15

ld A,DCR0H

ld A,1

ld DCR0L,A ;Set PWM duty cycle

ld A,$10

ld ATCSR,A ;

ld A,1

ld PWMCR,A ;bit 0=1 PWM output enabled.

ret

segment 'vectit'

DC.W 0 ; FFE0-FFE1h

DC.W 0 ; FFE2-FFE3h

DC.W 0 ; FFE4-FFE5h

DC.W 0 ; FFE6-FFE7h

DC.W 0 ; FFE8-FFE9h

DC.W 0 ; FFEA-FFEBh

DC.W 0 ; FFEC-FFEDh

DC.W 0 ; FFEE-FFEFh

DC.W 0 ; FFF0-FFF1h

DC.W 0 ; FFF2-FFF3h

DC.W 0 ; FFF4-FFF5h

DC.W 0 ; FFF6-FFF7h

DC.W 0 ; FFF8-FFF9h

DC.W 0 ; FFFA-FFFBh

DC.W 0 ; FFFC-FFFDh

DC.W main

simonharrison9
Associate II
Posted on December 03, 2002 at 10:25

Hi,

The simple answer is that the PWM is not running.

A small change is required:

.init_pwm

ld A,DCR0H should be ld DCR0H, A

regards,

Simon

Anglia Internal Apps Support