to UTFTGLUE.h for the ST core (1 error: lvalue required as left operand of assignment SS = (val & 0x40)?">

Error Lvalue Required As Left Operand Of Assignment Avr

  • 14th May 2015, 09:13#1

    Member level 2

    AVR code not working on Atmel Studio 6

    Hey there champions,
    I am back with another jug of problems.
    I have just started working on AVR Atmega16 microcontroller.
    And I am using Atmel Studio 6.
    I am very well familiar with the programming of PIC microcontroller on Microchip.
    And i find it quite easy to build.
    But i tried to program AVR in the same way of building logic as that of PIC and I it didn't work.
    Here is the code that I tried.

    PURPOSE OF CODE:
    To on an LED with a Button for ten seconds

    Here is the group of instructions that I wrote considering it complete code:
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

    Code:

    #include
    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    When I tried it on proteus, nothing happens no matter how many times i press the button.
    Plus there is an error of internal exception on proteus and it crashes.
    Any help would be greatly appreciated. It is urgent for me.
    So please someone look for it.
    Eagerly waiting for the reply.
    Thanks in advance.

    Last edited by bigdogguru; 15th May 2015 at 13:36. Reason: Added CODE or SYNTAX Tags


  • 14th May 2015, 13:51#2


    Re: AVR code not working on Atmel Studio 6

    Hi, LeoStar

    Code:

    #define SW1 PA0 //pin must be input (PINA.0 in CVAVR) #define LED1 PA1 void main() { DDRA=0xFE; PORTA=0x01; LED1<
    •   14th May 2015, 13:51


  • 14th May 2015, 14:05#3

    Banned

    Re: AVR code not working on Atmel Studio 6

    See if ADC has to be disabled to make the pins digital IO. For input PINA0 has to be used.

    I don't use Atmel Studio much. I use mikroC PRO AVR Compiler. Here I am attaching a working project. You can test it in hardware. It is compiled for 4 MHz external oscillator.

    I have tested this in Proteus and it works fine. You can download and install demo version of mikroC PRO AVR Compiler and open the .mcpav file.

    Last edited by milan.rajik; 14th May 2015 at 14:29.


  • 15th May 2015, 05:45#4

    Member level 2

    Re: AVR code not working on Atmel Studio 6

    Thank you so much for replying guys.
    DeepOne i tried your way and got the following error:

    for the following line:
    Please tell me how to resolve this.
    And the pin is already configured as input pin(DDRA=0xFE;).
    And Milan thanks for advicing regarding the ADC, I will disable them and try it once again.

    And I don't want to quit working on Atmel Studio 6 as it is new for me and adds variety to my software list.
    I will find some other way of programming but wont quit working on it.
    I will set it as my last resort to work with MIKRO C PRO AVR.
    Thanks a lot for your precious time guys.
    Looking forward to hear from you soon again.
    Error 3 lvalue required as left operand of assignment

    Last edited by bigdogguru; 15th May 2015 at 13:38. Reason: Added CODE or SYNTAX Tags and QUOTE Tags for readability


    •   15th May 2015, 05:45


  • 15th May 2015, 09:54#5


    Re: AVR code not working on Atmel Studio 6

    LED1=1< pin is already configured as input pin //of course, but it is necessary to address it as input register (PINA.0 in CVAVR)
    // ADC is already disabled after power on reset, according to datasheet

    •   15th May 2015, 09:54


  • 15th May 2015, 18:11#6


    Re: AVR code not working on Atmel Studio 6

    seems construction like PORTA.1 or PINA.0 is not work in Atmel Studio. So you may use equation like PORTA |= 1<

    Code:

    typedef unsigned int uint8_t; typedef struct Bits_t { uint8_t Bit0 :1; uint8_t Bit1 :1; uint8_t Bit2 :1; uint8_t Bit3 :1; uint8_t Bit4 :1; uint8_t Bit5 :1; uint8_t Bit6 :1; uint8_t Bit7 :1; }Bits; #define PortaBits (*((volatile Bits*)&PORTA)) #define PinaBits (*((volatile Bits*)&PINA)) #define LED1 PortaBits.Bit1 #define SW1 PinaBits.Bit0 void main() { DDRA=0xFE; PORTA=0x01; while(1) { if(SW1==0) { LED1=1; _delay_ms(10000); } else { LED1=0; } } }
  • 5th June 2015, 06:01#7

    Member level 2

    Re: AVR code not working on Atmel Studio 6

    Hello everyone,
    Long time no see.
    I have started working on MIKRO C PRO FOR AVR. I use it for pic as well and I consider it the best among the compilers.
    Here is the code that i am trying on it. It gets compiled without errors but when i try it on proteus the pin that is connected to led is low and the pin with the switch is high as well but when I push the button it doesnt work.
    Here is the code:
    *******************
    sbit SW1 at PinA.B0;
    sbit LED at PORTa.B1;
    void main()
    {
    DDRA=0xFE;
    PORTA.B0=1;
    if(!SW1)
    {
    LED=1;
    delay_ms(5000);
    }
    else
    LED=0;
    }
    +++++++++++++++++++++++++++
    And the attachment shows that the led doesn't glow even if the switch is pressed.

    Any help will be appreciated.

    And whenever I try it out on proteus there is an error and proteus crashes. I am attaching a snapshot of the error as well.

    Last edited by LeoStar; 5th June 2015 at 06:08. Reason: Updation regarding an erro


  • 5th June 2015, 06:59#8

    Banned

    Re: AVR code not working on Atmel Studio 6

    Try this project. It toggles LED on button press and release.


    Code C - [expand]
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 sbit SW at PINA.B0; sbit LED at PORTA.B1;   void main(){       DDRA =0xFE;     PORTA =0x00;         while(1){         if(!SW){            Delay_ms(50);            if(!SW);               LED =1;         }         elseif(SW){              Delay_ms(50);              if(SW)                LED =0;         }     }}

    Last edited by milan.rajik; 5th June 2015 at 07:13.


    •   5th June 2015, 06:59


  • 5th June 2015, 12:22#9

    Member level 2

    Re: AVR code not working on Atmel Studio 6

    Thank you for your reply Milan, my code worked on proteus as well and now I have learned programming for AVR as well. As i told before I was very comfortable working with MICRO C so I made it to work.
    Thanks a lot for your precious time.


  • 23rd October 2015, 07:30#10

    Newbie level 3

    Re: AVR code not working on Atmel Studio 6

    You may still interested to try once more with Atmel Studio 6. Here is a great post with video and description:
    http://www.binaryupdates.com/learn-p...crocontroller/

    Happy Programming

    Good Luck


  • 28th October 2015, 13:18#11

    Newbie level 5

    Re: AVR code not working on Atmel Studio 6

    If you want to learn more about different keywords used to define data types please refer here.

    http://embeddedcubes.blogspot.in/201...6t-int32t.html


  • 'L-value' and 'R-Value' describe attributes of the Left-hand side and Right-hand side, respectively, of an assignment. An R-value is a quantity of some kind (not necessarily numerical), usually the result of evaluating an expression, but also a constant, such as '5' or the string "Hello, World!\n". An L-value is a something that a program can assign an R-value to, such as a named variable, or a raw memory or port address. This WikiPedia article has a more complete description.

    "lvalue required as left operand of assignment" simply means that the left side of your assignment isn't an assignable address or convertible to one. PA0 is #defined as a simple constant without l-value properties.

    You're on the right track - here is an Arduino article about ports and the I/O registers associated with them, and direct manipulation of those registers. Despite its caveats, direct port manipulation is a useful technique for reducing both program size and timing-skew in some situations.

    These statements:

    will both define an l-value you can assign to (but note: it's a whole port, not just a pin) and change its value to turn on pin-0. The RED_ON expression reads: read PORTA, OR that with '1' (so you won't change any other bits in the port); the assignment writes the new value back to the port.

    (Do note that your code as written - even assuming the assignment statement was correct - will repetitively turn on the LED, which is no different from turning it on once).

    answered Jun 18 '12 at 18:35

    Categories: 1

    0 Replies to “Error Lvalue Required As Left Operand Of Assignment Avr”

    Leave a comment

    L'indirizzo email non verrĂ  pubblicato. I campi obbligatori sono contrassegnati *