Menu

avr: asm command sleep

tomtom
2016-12-12
2016-12-16
  • tomtom

    tomtom - 2016-12-12

    Hello,
    I try to send the controller to sleep. But instead of a sllep command the compiler create a "3". see below.

    The GCB code

      SMCR.SE = 1
      asm sleep
    

    The asm code look like this:

    ;SMCR.SE = 1
    in SysValueCopy,SMCR
    sbr SysValueCopy,1<<SE
    out SMCR,SysValueCopy

    ;asm sleep
    3

    GCASM create such report
    A warning has been generated:
    Warning: GCASM: Value out of range: Least significant bits used

    Chip: MEGA328P
    Compiler Version: 0.95 2016-06-26

     
  • tomtom

    tomtom - 2016-12-12

    I slove the Problem

    befor the code above I have a Select Case Statement. The variable in the Statment can have 3 Values
    .#define sleep 1
    .#define on 2
    .#define off 1

    In the first Definition was the Problem. The Defninition sleep clash with the asm Statment

     
    • Hugh Considine

      Hugh Considine - 2016-12-13

      You might also have some problems with on and off. These are defined by the compiler as 1 and 0, and used internally in quite a few places. Setting them to 2 and 1 could cause problems, it would be safer to rename these constants (or use the compiler's own definition of On = 1 and Off = 0 if you can).

       
  • Anobium

    Anobium - 2016-12-13

    And, if you would like a simple list of all the reserved commands, the following general rules apply.

    1. Look in your installation for ..\GCB@Syn\SynWrite\Data\autocomplete\GreatCowBasic.gcb - this file has the command set. Do not use these as varaibles unless you intended to.
    2. Do not create variables or constants that use any registers or bits specified in the chip specific datasheet unless you know what you are doing.
    3. Look in your ASM file. All your defined variables are shown is you review the section where all the vairables are defined then this can really help understand if you have an errant variable description. You will also see the variables used by the Great Cow BASIC libraries.
     
  • tomtom

    tomtom - 2016-12-16

    Thank you for the Reply. Hugh and Anobium.
    The comments help me.
    The "GreatCowBasic.gcb" is a good Tip

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.