Society of Robots - Robot Forum

Software => Software => Topic started by: PtMartins on June 16, 2009, 05:26:36 PM

Title: trouble clearing a bit
Post by: PtMartins on June 16, 2009, 05:26:36 PM
Hi,

After solving my power issues on the axon  :) I have a programming question.

I use all the time the cbi and sbi functions to clear and set bits, and they seem to work.

But in this code:

Code: [Select]
void LeftWheellBackON(){
//sbi(PINC,1);
PORT_ON(PINC,1);
}

void LeftWheellBackOFF(){
cbi(PINC,PC1);
//PORT_OFF(PINC,1);
//FLIP_PORT(PINC, 1);
}

The sbi doesn't work.

I call the LeftWheellBackON() and my encoder is instructed to turn left motor ON (back direction). Then If I cal lLeftWheellBackOFF(), the motor doesn't stop. My program continues normally, but the pin 1 is high....

I tried the commented functions also... I switch to portC 7, but the same occurs...

The PWM works fine turning on and off, and i use it for front motion.

Any ideas ??

Thanks
Title: Re: trouble clearing a bit
Post by: chelmi on June 16, 2009, 09:00:56 PM
it's probably not the problem, but sbi and cbi are deprecated.
http://www.gnu.org/savannah-checkouts/non-gnu/avr-libc/user-manual/group__avr__sfr.html (http://www.gnu.org/savannah-checkouts/non-gnu/avr-libc/user-manual/group__avr__sfr.html)

did you try

PORTC |= _BV(PC1) to turn it on
and
PORTC &= ~_BV(PC1) to turn it off ?
Title: Re: trouble clearing a bit
Post by: PtMartins on June 17, 2009, 04:13:38 PM
The link you posted is down, but that was the problem !!! It's fine now !

Does that mean that I have to update my avrlib ?

Thanks for your help.
Title: Re: trouble clearing a bit
Post by: chelmi on June 18, 2009, 09:54:53 AM
The link you posted is down, but that was the problem !!! It's fine now !

Does that mean that I have to update my avrlib ?

Thanks for your help.

Your welcome !

I fixed the link, it should work now.

AFAIK avrlib is not maintained. I've heard of a project to revive it but I can't find it. You probably have the last version.