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

BASCOM-AVR : ATmega8 : NEWTOPIC

$
0
0
I'm having a problem controlling an ATMEG8 output. I have all of port b set as outputs. I have timer one set up for pulse width modulation with the output on OC1A (pin 1 port b). It's set up like this: "Config Timer1 = Pwm , Pwm = 10 , Compare_a_pwm = Clear_down , Compare_b_pwm = disconnect , Prescale = 1" This works as intended. I wanted to use PB0 as an output, It seems to work if I just turn it on or off. But when I want to turn it on/off via the serial port (rs232) it does not work correctly. All other port b outputs work as expected. Port b 0(pin zer0) seems to be pwm at a 50% duty cycle. For instance, If I tell it to turn on for maybe 2 milliseconds, It will go high for one millisecond, then low for the other millisecond. I was under the assumption that when you used Compare_b_pwm = disconnect on timer one, that it should disconnect that pin from the timer output. This seems to be true as I can manually turn it on/off, but when trying to pulse it, I get a duty cycle in it. Some code from the affected section of the program: '------------------------------------------------------------------------------- 'Sub: Go Forward: moves the solenoid in the foward direction. '------------------------------------------------------------------------------- Sub Go_Forward PortD.4 = 0 '- PortD PD4 Low level signal (Led Reverse indication) PortD.5 = 1 '- PortD PD5 Low level signal (Led Forward indication) Start Timer2 '- Prepare the timer to start up TimerValue = 0 '- Reset the timer value to zero Portb.0 = 1 '- PortB PB0 Low level signal (Output for switching the h-bridge) Portb.2 = 0 '- PortB PB2 Low level signal (Output for switching the h-bridge) do Loop Until TimerValue = TargetTime '- Loop until target time is reached Portb.0 = 0 '- PortB PB3 Low level signal (Output for switching the h-bridge) Portb.2 = 0 '- PortB PB4 Low level signal (Output for switching the h-bridge) PortD.4 = 0 '- PortD PD4 Low level signal (Led forward indication) PortD.5 = 0 '- PortD PD5 Low level signal (Led Reverse indication) Stop Timer2 TimerValue = 0 '- Reset the timer value to zero Print "OK" End Sub That code above works great for any other pin except Port B pin 0. Any ideas what could be going on? Thanks in advance, Robert [b:371b041fe9][color=red:371b041fe9](BASCOM-AVR version : 2.0.7.6 )[/b:371b041fe9][/color:371b041fe9]

Viewing all articles
Browse latest Browse all 20563

Trending Articles



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