This is for mcs51, and the specific MCU is a CH552.

Here's my pushPull function:

// set GPIO to push-pull mode
inline void pushPull(uint8_t pinaddr)
{
    if (pinaddr >= 0xB0 && pinaddr < 0xB8)
        P3_MOD_OC &= ~(1 << (pinaddr - 0xB0));
    else if (pinaddr >= 0x90 && pinaddr < 0x98)
        P1_MOD_OC &= ~(1 << (pinaddr - 0x90));
}

On Sat, Mar 6, 2021 at 1:12 PM Maarten Brock <sourceforge.br...@dse.nl> wrote:
>
> Ralph Doncaster schreef op 2021-02-18 16:33:
> > If I have an sbit defined as follows:
> > __sbit __at (0x90) LED;
> >
> > How can I get the address?  When I try &LED, I get an error:
> > error 35: '&' illegal operand, address of bit variable
> >
> > I need the address for a function that will configure the GPIO to
> > push-pull
> > mode.  I can hack it with some inline assembler:
> > __asm
> > mov dpl, #_LED
> > lcall _pushPull
> > __endasm;
> >
> > Is there a way to do it in C?
>
> On which MCU are you trying to do this? And what will pushPull do with
> that address?
> On most mcs51 derivatives all SFRs are in direct space only and cannot
> be accessed indirectly.
>
> Maarten
>
>
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to