I'm new to Atmel Studio. I used BASCOM-AVR until now. I know my question is very basic but I couldn't solve my problem by searching internet.
I wrote a code in BASCOM (Basic laguage) to control two DC motors using ATmega32 and L298n. Here is a part of it:
$regfile = "m32def.dat" $crystal = 1000000 Config Timer1 = Pwm , Pwm = 10 , Compare_A_Pwm = Clear_Up , Compare_B_Pwm = Clear_Up , Prescale = 1 'D.0 and D.1 for right, D.2 and D.3 for left Config PortD.3 = Output Config PortD.2 = Output Config PortD.1 = Output Config PortD.0 = Output 'pwm1a for left motor, pwm1b for right motor Do reset portd.1 reset portd.2 set portd.0 set portd.3 pwm1b = 500 pwm1a = 1023 waitms 2000 reset portd.0 reset portd.3 set portd.1 set portd.2 pwm1b = 1023 pwm1a = 500 waitms 2000 Loop End
Now I want to convert it to "C" for Atmel Studio but I can't understand syntax for PWM in C.
Also, I didn't understand the way to set just a pin to 0 or 1 (not a port). I mean, if I write (in Atmel Studio):
PORTD = 0b00001001;
pind0 and pind3 are high and pind1 and pind2 are low but I'm worried if setting pind4...7 to 0 affects PWM (Because PD4 and PD5 are for PWM).
Could you please explane me syntax of PWM in C and answer my second question?
It would be very good if you convert my code to C and explane C by comparing it to Basic! :)