NXP P89C669 and extended SFR's

Help
Anonymous
2010-09-29
2013-03-12

  • Anonymous
    2010-09-29

    Hi,

    I'm trying to use the second serial port on an P89C669.  The registers for which (S1CON, S1DAT…) are "extended SFR's".

    From the datasheet: "When any instruction that references an SFR (including a bit address in an SFR) is preceded by the escape opcode A5h, an alternate bank of SFRs (extended SFRs) will be accessed. "
    (From: http://www.keil.com/dd/docs/datashts/philips/51mx_arch_ism.pdf  page 12)

    Does SDCC have any facility for doing this?   I don't even know how I would write this in inline assembly.

    Thanks
    Nick

     
  • Hi,

    Am 29.09.2010 22:29, schrieb SourceForge.net:
    > I'm trying to use the second serial port on an P89C669.  The registers for which
    > (S1CON, S1DAT…) are "extended SFR's".
    >
    >>From the datasheet: "When any instruction that references an SFR (including
    > a bit address in an SFR) is preceded by the escape opcode A5h, an alternate
    > bank of SFRs (extended SFRs) will be accessed. "
    > (From: http://www.keil.com/dd/docs/datashts/philips/51mx_arch_ism.pdf  page 12)
    >
    > Does SDCC have any facility for doing this?

    No.

    > I don't even know how I would write this in inline assembly.

    Something like this MAY work:

    --8<-------------------------------------------
    #define SFR_x   __asm \
                     .db 0xa5 \
                    __endasm
    #define get_SFR_x(src, dst) __asm \
                                .db 0xa5 \
                                mov a,_##src \
                                mov _##dst,a \
                            __endasm
    __sfr __at (0xfb) SPE_x;
    unsigned char __data c;
    void main(void)
    {
      SFR_x; SPE_x = 1;
      SFR_x; SPE_x = 0;
      get_SFR_x(SPE_x, c);
    }
    -->8-------------------------------------------
    Note, get_SFR_x() is just a hack and generates
    pretty strange input for the assembler.
    Which probably 'just happens to give the desired
    result' here.
    --8<-------------------------------------------
                                138 ;       inline4.c:19: SFR_x; SPE_x = 1;
       0064 A5                  139          .db 0xa5 
       0065 75 FB 01            140         mov     _SPE_x,#0x01
                                141 ;       inline4.c:21: SFR_x; SPE_x = 0;
       0068 A5                  142          .db 0xa5 
       0069 75 FB 00            143         mov     _SPE_x,#0x00
                                144 ;       inline4.c:23: get_SFR_x(SPE_x, c);
       006C A5 E5 FB F5 08      145          .db 0xa5 mov a,_SPE_x mov _c,a 
       0071 22                  146         ret
    -->8-------------------------------------------
    

    (it might be cleaner to have a helper function
    for each of the registers you want to read back
    or write with a non-literal.)

    Greetings,
    Frieder

     

  • Anonymous
    2010-09-30

    Hi,

    Wow, brilliant, thanks that worked great.

    Slightly OT, but… I guess interrupts need to be disabled when doing this, so it's not interrupted between the 0xA5 and the mov?

    Thanks
    Nick

     
  • Maarten Brock
    Maarten Brock
    2010-10-04

    I don't think interrupts need to be disabled as the 0xA5 and following opcode will probably be treated as a single (multi-byte) instruction by the core.

    Maarten