Setting C bit from a variable in AVR

joe rocci
2014-05-20
2014-05-22
  • joe rocci

    joe rocci - 2014-05-20

    Platform: Arduino w/ATMEGA328P, 16 Mhz

    Setting up for a "Rotate" operation, the following is accepted by the compiler:
    C = 0
    or
    C = 1

    The following causes a compiler error:
    Dim myBit as bit
    myBit = 0
    C = myBit

    Error Message:
    AVR C bit problem.gcb (5): Error: Invalid variable name: C
    AVR C bit problem.gcb (5): Warning: Variable name C is used for a system bit on the current chip

    Is there a way to set C from a variable?

    Joe

     
  • Anonymous - 2014-05-22

    A while back I did some bit-twiddling with the carry bit. The goal was to turn on one and only one bit in a byte specified by a number. Here's the code:

        number = number - ASCIIzero       ;convert from ASCII to number
    
        pattern = 0                       ;now extract which LED to light
        status.c = 1                      ;set the carry flag
        for i = 0 to number               ;rotate to correct position
          rotate pattern left
        next i
    
        LEDs = pattern                    ;then light the LED
    

    Maybe that'll give you an idea.

    Thomas henry

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks