Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20599

BASCOM-AVR : PWM on other port : REPLY

$
0
0
Actually it depends on what your controller has to do beside the PWMs. This small program lets you use your PORTC2+3 instead of PORTD5+6. But the ISRs take some time (which could be reduced by applying the Nosave option): [code:1:99851061bf]$regfile = "m32def.dat" $crystal = 16000000 $baud = 115200 Config Portc.2 = Output Config Portc.3 = Output Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 64 , Compare_a = Disconnect , Compare_b = Disconnect On Compare1a Compa_isr On Compare1b Compb_isr Enable Compare1a Enable Compare1b Pwm1a = 2 Pwm1b = 2 Enable Interrupts Do Waitms 10 Incr Pwm1a : If Pwm1a = 1022 Then Pwm1a = 2 Incr Pwm1b : If Pwm1b = 1022 Then Pwm1b = 2 Loop Compa_isr: Toggle Portc.2 Return Compb_isr: Toggle Portc.3 Return[/code:1:99851061bf] I have avoided the end positions pwm1a=0 and pwm1a=1023, because interrupts would occur to fast without Nosave.

Viewing all articles
Browse latest Browse all 20599

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>