Author Topic: trouble clearing a bit  (Read 2015 times)

0 Members and 1 Guest are viewing this topic.

Offline PtMartinsTopic starter

  • Jr. Member
  • **
  • Posts: 17
  • Helpful? 0
trouble clearing a bit
« 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

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
    • Current projects
Re: trouble clearing a bit
« Reply #1 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

did you try

PORTC |= _BV(PC1) to turn it on
and
PORTC &= ~_BV(PC1) to turn it off ?
« Last Edit: June 18, 2009, 09:44:33 AM by chelmi »

Offline PtMartinsTopic starter

  • Jr. Member
  • **
  • Posts: 17
  • Helpful? 0
Re: trouble clearing a bit
« Reply #2 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.

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
    • Current projects
Re: trouble clearing a bit
« Reply #3 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.