This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Changing 8051 declarations to match CCS4 C

Hi,

I want to program a Mifare card reader chip RC522 using dk-lm3s9b96. I'm new to this, so I thought I should start off with the sample code given in NXP website. But when I tried compiling the code, I realised 'sfr' and 'sbit' declarations are not accepted by CCS4.

Any idea how I can change those declarations so that the code can be compiled?

  • You are trying to use example code for a completely different device to program the LM3S9B96 so there could be many differences which are not directly translatable. To migrate the code would involve an understanding of what the code is doing and then translating that to equivalent code for Stellaris using the Stellaris header files and libraries. I would suggest starting with Stellarisware which is our software suite designed to speed up development with Stellaris microncontrollers, to see if some of the examples there are helpful.

  • Thanks Aarti,

     I think I got that part. But I'm not sure how 'sfr's could be written for stellarisware.

    Take reg52.h for example:

    /*  BYTE Registers  */

    sfr P0    = 0x80;

    sfr P1    = 0x90;

    sfr P2    = 0xA0;

    sfr P3    = 0xB0;

    sfr PSW   = 0xD0;

    sfr ACC   = 0xE0;

    sfr B     = 0xF0;

    sfr SP    = 0x81;

    sfr DPL   = 0x82;

    sfr DPH   = 0x83;

    sfr PCON  = 0x87;

    sfr TCON  = 0x88;

    sfr TMOD  = 0x89;

    sfr TL0   = 0x8A;

    sfr TL1   = 0x8B;

    sfr TH0   = 0x8C;

    sfr TH1   = 0x8D;

    sfr IE    = 0xA8;

    sfr IP    = 0xB8;

    sfr SCON  = 0x98;

    sfr SBUF  = 0x99;

     

    How do I even start re-declaring them for lm3s9b96?

     

    Completely Clueless :S

  • Tridib,

    SFR's on the 8051 processor are special registers that have special access addressing and work very much like peripheral memory mapped registers.  These are unlikely to map directly as the peripherals are significantly different on the two processors.  The sbit type is a bit addressable type.  The 8051 processor reserves every eighth address in the idata and SFR memory spaces to allow bit addressing of these memory locations.  Special opcodes and addressing modes are used.  To map these you will have to do bit manipulation using the bitwise and, or, and xor operators and their assignment counterparts as well.

    Note that code written to access registers like these would generally be considered device driver code.  Usually device driver code is unique to each processor/peripheral so it is unlikely you will be able to simply remap the 8051 code to woek on a stellaris processor.

    Jim