It shows the NSS signal (ie., slave select for the MFRC522) is a low true
signal. But you have it set for high true in the #use SPI() statement
above. Fix that.

Also, in the #use spi() line above, you don't have FORCE_HW specified
so the CCS compiler will put in software SPI code. It will use bit-banging
to do the SPI. I'm just making you aware of that.

Also, in the #use spi() statement, you didn't specify the SPI mode.
That's important. The MFRC522 appears to use Mode 0. You need to
add a parameter to the #use spi() to specify that. See the CCS manual.

Here you have reversed the pins from the hardware assignments on the
16F887. Look at the pinout for the 40-pin package in the 16F887 data
sheet. Because you have done this, the compiler will create a software
UART on those pins. And, it won't inform you of this. Change the pins
to the correct pins for the hardware UART. Then you'll get hardware UART
code from the compiler. Also, we like to add the ERRORS parameter
to the #use rs232() statement above.

Variable declarations go at the start of a function. Don't put lines of
code above any variable declarations. Also, you're changing the case
and you're using aliases for data types. This is very poor technique.
CCS is case-insensitive by default. Most C compilers are not. It's a bad
habit to get into. Also 'int' is the same as 'int8' in CCS. They are both
unsigned 8-bit integers. It's suggested that you use 'int8' when writing
CCS programs.

Here, you are manually controlling the Slave Select line on pin C2.
But you have told the compiler to do it in the #use spi() statement.
So why do it manually again ? It's not needed. And the way you're
doing it is incorrect, because the MFRC522 data sheet shows that
Slave Select is active low. You're controlling it as if it's active high.
It wouldn't work. Get rid of those two lines in bold above.

ckielstra

Joined: 18 Mar 2004Posts: 3680Location: The Netherlands

Posted: Tue Oct 29, 2013 3:01 pm

Such a short program and so many problems detected by PCM Programmer.
Couldn't help myself to point another problem: