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

different notation

Hello guys,

just a silly question,
is it possible to modify code to a different notation:

//**************************************************************************
void SPI_send_8(unsigned int a)
{
        SPITX = a;
        while(!(SPISTA & 0x04)){}
}
//**************************************************************************

to:

//**************************************************************************
void SPI_send_8(unsigned int SPITX)
{
        while(!(SPISTA & 0x04)){}
}
//**************************************************************************


SPITX is the SPI TX.

Parents
  • The "SPITX" variable you want to work with is a SFR, i.e. a magic global variable that maps to the hardware. Because of this, you can not do any rewrites and create own variables with the same name and still get the intended behaviour.

    Some compilers may declare SFR (Special Function Registers) as external variables at fixed location, and some compilers will have an include file that uses the preprocessor to convert the SFR name into direct pointer manipulation to access the relevant address.

    If the compiler uses external variables, you will be able to create local variables with the same name - but obviously with different behaviour. If the compiler uses the preprocessor, your code will be completely garbled when the preprocessor performs the same replace operations even where the syntax can't be accepted. Your parameter name may be expanded into *(unsigned int*)(0xabcd1234) which is obviously not an allowed parameter name.

Reply
  • The "SPITX" variable you want to work with is a SFR, i.e. a magic global variable that maps to the hardware. Because of this, you can not do any rewrites and create own variables with the same name and still get the intended behaviour.

    Some compilers may declare SFR (Special Function Registers) as external variables at fixed location, and some compilers will have an include file that uses the preprocessor to convert the SFR name into direct pointer manipulation to access the relevant address.

    If the compiler uses external variables, you will be able to create local variables with the same name - but obviously with different behaviour. If the compiler uses the preprocessor, your code will be completely garbled when the preprocessor performs the same replace operations even where the syntax can't be accepted. Your parameter name may be expanded into *(unsigned int*)(0xabcd1234) which is obviously not an allowed parameter name.

Children
No data