Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RC522 and PIC18F47k40

Status
Not open for further replies.

Jair.Hdez

Newbie level 3
Newbie level 3
Joined
Oct 18, 2017
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
41
Hi all,

I want to check the version from the RC522 using SPI with the PIC18F47K40 to check if the communication between the RFID and the pic. I'm supposed to get 0x91 or 0x92 but I'm getting 0x67. Also if I try to read the id from a card I get no answer from the RFID. My connection between the rfid and the pic are:

MFRC522 PIC18F47K40
SDA RC3 - 18th pin
SCK RC2 - 17th pin
MOSI RC1 - 16th pin
MISO RC0 - 15th pin
Reset RA0 - 2nd pin

The pic and the rfid are powered with 3.3V.
I'm using the latest version of MikroC.

My project is attached View attachment rfid.zip
 

Hello,

i tested this board **broken link removed**, but used SPI2
because SPI1 pins used for a I2C LCD

18F45K22_MSSP2_SPI_diagram.jpg

and used this LIB

an UART output for debugging is very usefull to follow the program and debug ...
ID number is detected ansd stored in PIC EEPROM
LCD 2x16 is used to follow the process.
UART is used only during debugging phase.. but could be used for Bluetooth link with a phone android application


your Zip doesn't compile without errors !


184 324 Undeclared identifier 'Uart1_Escribir_Texto' in expression FIRMWARE_DEON_UTR_PDS_V1_BASE_U1.c
185 324 Undeclared identifier 'status' in expression FIRMWARE_DEON_UTR_PDS_V1_BASE_U1.c



Code:
	UART1_Write(status1);  (was status)
i replace Uart1_Escribir_Texto by

Code:
void UART1_Write_CText(const char *T)
{ char c;
while(*(T)>0)
{ c=*(T);
  UART1_Write(c);
  T++;
 }
 }
 #define  Uart1_Escribir_Texto  UART1_Write_CText
to get a good compile ..


you project tell 64Mhz Fosc !
did you try at lower speed , because you are using Software SPI ...
 
Last edited:

I can help only with my own library for RC522. Works perfect in one of my projects, but requires some knowledges of C.
 

First of all thanks paul and easyrider.

paulfjujo, Uart1_Escribir_Texto I got it inside a library that I included in MikroC but it is alike the one you wrote. I changed the "UART1_Write(status1);" line as you said and now I watch 0x00 instead of 0x67. I think you wrote this **broken link removed** right? I got the getVersion function from there. Also I would like to use the hardware SPI. I tried the next changes

Code:
... 
sbit MFRC522_CS at LATC.B3;
sbit MFRC522_Rst at LATA.B0;
//sbit SoftSPI_SDO at LATC.B1;
//sbit SoftSPI_CLK at LATC.B2;
//sbit SoftSPI_SDI at LATC.B0;
sbit MFRC522_CS_Direction at TRISC3_Bit;
sbit MFRC522_Rst_Direction at TRISA0_Bit;
//sbit SoftSPI_SDO_Direction at TRISC1_Bit;
//sbit SoftSPI_CLK_Direction at TRISC2_Bit;
//sbit SoftSPI_SDI_Direction at TRISC0_Bit;
...
inside main 
...
//Soft_SPI_Init();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
...
inside InitMCU
...
SSP1DATPPS = 0x10;            // SDI en pin RC0
RC1PPS = 0x10;                // SDO en pin RC1
RC2PPS = 0x0F;                // SCK en pin RC2
...
static void MFRC522_Wr( char addr, char value )
{
        MFRC522_CS = 0;
        SPI1_Write( 0x00 );
        SPI1_Write( ( addr << 1 ) & 0x7E );
        SPI1_Write( value );
        MFRC522_CS = 1;
}

static char MFRC522_Rd( char addr )
{
        char value;
        MFRC522_CS = 0;
        SPI1_Write( (( addr << 1 ) & 0x7E) | 0x80 );
        value = SPI1_Read( 0x00 );
        MFRC522_CS = 1;
        return value;
}

but I got the same results.

EasyRaider, I would like to try to use your library if you like to give it to me.

I attach the project with the modificationsView attachment rfid2.zip
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top