Re: PWM for my ATmega32.
sample:
$regfile = "attiny2313.dat"
$crystal = 12000000
Config Portb = Output
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Prescale = 64
Pwm1a = 255
Do
Loop
End
For atmega32 :
$ regfile = "M32def.dat"
'Uncomment the following code to disable JTAG
Mcusr = &H80
'Mcusr = &H80
'tell the compiler which XTAL was used
$ crystal = 8000000
Startup:
Ddrb.3 = 1 'make pin4, portb.3 OC0 an output to drive LED
Tccr0 = &B01101001 'timer0 in fast pwm mode, prescale = 1
'Tccr0 = &B01101010 'timer0 in fast pwm mode, prescale = 8
'Tccr0 = &B01101011 'timer0 in fast pwm mode, prescale = 64
'Tccr0 = &B01101100 'timer0 in fast pwm mode, prescale = 256
'Tccr0 = &B01101101 'timer0 in fast pwm mode, prescale = 1024
'Tccr0 = &B01101101 'timer0 in fast pwm mode, external clock on t0 pin, falling edge
'Tccr0 = &B01101111 'timer0 in fast pwm mode, external clock on t0 pin, rising edge
Ocr0 = 0 'set the PWM value for timer0 to zero (0)
Do 'do this
Incr Ocr0 'add 1 to the PWM0 setting OCR0 means output compare register zero
Waitms 10 'stay on this ocr0 setting for 10 milliseconds
Loop
'end of PWM0 code
Compiler is BAscom AVR -free 2k of cobe