This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SFR not included in comercial Chip

Dear Sr.
Can i access registers (reading and writing) SFR inserted at different addresses from the comercial 8051 ones? For example the following addresses registers are not accessible for writing:
SFR LDO_CTRL = 0xC0;
SFR CH1 sfr = 0xC5;
sfr CH2 = 0xC6;
SFR RX_F1 = 0xC9;
SFR RX_F2 = 0xCA;
SFR RX_P1 = 0xCB;
SFR RX_P2 = 0xCC;

KEIL IDE displays the following message:

SFR_EXTRAS1.C(38): error C202: 'LDO_CTRL': undefined identifier
SFR_EXTRAS1.C(43): error C202: 'CH1': undefined identifier
SFR_EXTRAS1.C(44): error C202: 'CH2': undefined identifier
SFR_EXTRAS1.C(45): error C202: 'RX_F1': undefined identifier
SFR_EXTRAS1.C(46): error C202: 'RX_F2': undefined identifier
SFR_EXTRAS1.C(47): error C202: 'RX_P1': undefined identifier
SFR_EXTRAS1.C(48): error C202: 'RX_P2': undefined identifier


  • Yes.

    The Keil C51 compiler has no inherent knowledge of the "standard" (or any other) SFR addresses - all it knows is what you tell it in your SFR definitions.

    http://www.keil.com/support/man/docs/c51/c51_le_sfrs.htm

    For "standard" chips, Keil supply headers with the appropriate definitions. There is nothing magic or special about these; they are just header files, the same as any other header files - so you can just create your own headers with your own "non-standard" definitions.

    SFR LDO_CTRL = 0xC0;
    SFR CH1 sfr = 0xC5;
    

    Note the correct syntax here: http://www.keil.com/support/man/docs/c51/c51_le_sfr.htm - remember that 'C' (and, therefore, C51) is case-sensitive...

    SFR_EXTRAS1.C(38): error C202: 'LDO_CTRL': undefined identifier
    

    That's just telling you that you have not given any definition for 'LDO_CTRL' - it has nothing to do with SFRs

  • That refers specifically to the C51 Compiler - the A51 Assembler is different:

    http://www.keil.com/support/man/docs/a51/a51_nomod51.htm

  • Hello Andrew,
    I made some corrections in "hearder" file . Thanks for the guidance.
    Interestingly, for some addresses of SFR had no problems, then a part of the header and Error Message.

    At the end of this message is displayed error messages

    Header:
    LDO_CTRL sfr = 0xC0;
    ENABLE1 sfr = 0xC1;
    ENABLE2 sfr = 0xC2;
    SYNTH1 sfr = 0xC3;
    SYNTH2 sfr = 0xC4;
    CH1 sfr = 0xC5;
    sfr CH2 = 0xC6;
    RX_F1 sfr = 0xC9;
    RX_F2 sfr = 0xCA;
    RX_P1 sfr = 0xCB;
    RX_P2 sfr = 0xCC;
    TRANSCEIVER_CTRL sfr = 0xCE;
    sfr PSW = 0xD0;
    TX_A1 sfr = 0xD1;
    TX_A2 sfr = 0xD2;
    I2CSM_SETUP sfr = 0xD8;
    sfr ACC = 0xE0;
    I2CSM_STATUS sfr = 0xE8;

    Error Message
    Hello Andrew,
    I made some corrections in "hearder" Thanks for the guidance.
    Interestingly, for some addresses of SFR had no problems, then a part of the header and source code.

    At the end of this message is displayed error messages

    Header:
    LDO_CTRL sfr = 0xC0;
    ENABLE1 sfr = 0xC1;
    ENABLE2 sfr = 0xC2;
    SYNTH1 sfr = 0xC3;
    SYNTH2 sfr = 0xC4;
    CH1 sfr = 0xC5;
    sfr CH2 = 0xC6;
    RX_F1 sfr = 0xC9;
    RX_F2 sfr = 0xCA;
    RX_P1 sfr = 0xCB;
    RX_P2 sfr = 0xCC;
    TRANSCEIVER_CTRL sfr = 0xCE;
    sfr PSW = 0xD0;
    TX_A1 sfr = 0xD1;
    TX_A2 sfr = 0xD2;
    I2CSM_SETUP sfr = 0xD8;
    sfr ACC = 0xE0;
    I2CSM_STATUS sfr = 0xE8;

    Error Message
    SFR_EXTRAS1.C(38): error C202: 'LDO_CTRL': undefined identifier
    SFR_EXTRAS1.C(43): error C202: 'CH1': undefined identifier
    SFR_EXTRAS1.C(44): error C202: 'CH2': undefined identifier
    SFR_EXTRAS1.C(45): error C202: 'RX_F1': undefined identifier
    SFR_EXTRAS1.C(46): error C202: 'RX_F2': undefined identifier
    SFR_EXTRAS1.C(47): error C202: 'RX_P1': undefined identifier
    SFR_EXTRAS1.C(48): error C202: 'RX_P2': undefined identifier
    SFR_EXTRAS1.C(53): error C202: 'LDO_CTRL': undefined identifier

    Piece of the Source Code :
    "
    while (1) { LDO_CTRL = 0X01; ENABLE1 = 0XFE; ENABLE2 = 0XFF; SYNTH1 = 0XFE; SYNTH2 = 0XFF; CH1 = 0XFE; CH2 = 0XFF; RX_F1 = 0XFE; RX_F2 = 0XFF; RX_P1 = 0XFE; RX_P2 = 0XFF; TRANSCEIVER_CTRL = 0XFE; TX_A1 = 0XFE; TX_A2 = 0XFF;
    "

  • I'm sorry,
    the reserved word "sfr" was mistakenly inserted after the name of the register SFR, but the header file this error does not occur.

    Claudionor Santos

  • So, what are you saying?

    Do not manually re-type code into your post - use copy-and-paste.

    And pay attention to the instructions for posting source code:

    www.danlhenry.com/.../keil_code.png

    And pay attention to the 'Preview' to ensure that it's correct before you post it.

  • Andrew, thanks for the tips.

    The errors presented in the messages have been corrected.

    Thanks,
    Claudionor.