Salve,
Con un Atmega8 con quarzo 4Mhz, posso avere un pwm, o un segnale a onda quadra con frequenza di 670KHz?
Grazie
$regfile = "m8def.dat"
$crystal = 4000000
Config Portb.1 = Output 'PWM_PIN
Const Cpwmfreq = 5
Tccr1a = &B10000010
'Bit 7:6 – COM1A1:0: Compare Output Mode for channel A set to 10
' = Clear OC1A on Compare Match, set OC1A at TOP
'Bit 5:4 – COM1B1:0: Compare Output Mode for channel B set to 00
' = Normal port operation, OC1B disconnected.
'Bit 3 – FOC1A: Force Output Compare for channel A set to 0 - not used in PWM
'Bit 2 – FOC1B: Force Output Compare for channel B set to 0 - not used in PWM
'Bit 1:0 – WGM11:0: Waveform Generation Mode set to ..10
' = lower bits of Mode 14: fast PWM; TOP = ICR1
Tccr1b = &B00011001
'Bit 7 – ICNC1: Input Capture Noise Canceler set to 0 - not used in PWM
'Bit 6 – ICES1: Input Capture Edge Select set to 0 - not used in PWM
'Bit 5 – Reserved Bit set to 0
'Bit 4:3 – WGM13:2: Waveform Generation Mode set to 11..
' = higher bits of Mode 14: fast PWM; TOP = ICR1
'Bit 2:0 – CS12:0: Clock Select set to
' = higher bits of Mode 14: fast PWM; TOP = ICR1
'Bit 2:0 – CS12:0: Clock Select set to 010 = clkI/O / 8 (From prescaler)
Icr1 = Cpwmfreq
I = Cpwmfreq / 2 '50%
Pwm1a = I
....
Users browsing this forum: No registered users and 16 guests