Microcontroller › PIC › RFID MF522 – AN and PIC 18F4550
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by AJISH ALFRED.
-
AuthorPosts
-
September 1, 2014 at 2:03 am #4894EversonParticipant
Hi friends,
I’m trying to create a project that can read the RFID card.
I’m using this RFID module: MF522-AN that is connected like this.
PINS that I’m using on PIC:
SS – PIN_B2 (Just to send high or low)
SCK – PIN_B1
MISO – PIN_C7
MOSI – PIN_B0
Today I have connected using serial, just to send de computer information. The serial is OK, function normally.
But when I get the card and approach the RFID module does not nothing. ( The thing strange is that when I approach the hand on wire, PIC read something but just crazy characters.
This is my code that I’m using in CCS compiler.
#include <18F4550.h>
#device adc=8#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)#define SPI_MODE_1 (SPI_L_TO_H)#define SPI_MODE_2 (SPI_H_TO_L)#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)#define CS PIN_B2#define SCK PIN_B1#define SDO PIN_C7#define SDI PIN_B0#use delay (clock=48000000)#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,stop=1,parity=N, bits =#use SPI(SLAVE, BITS=8, BAUD=9600, DO = SDI, DI = SDO, CLK = SCK, ENABLE=CS, MSB_FIRST, stream = RFID, ENABLE_ACTIVE=1)#FUSES HSPLL ,PLL5, CPUDIV1, USBDIV VREGEN, ICPRT, NOWDT, NOBROWNOUT, NOPROTECTvoid main(){setup_comparator(NC_NC_NC_NC);int i=0;char value[8]=”n”;char x0;int16 result;int8 res;printf(“Iniciando…”);while(TRUE){output_high(pin_C2);delay_ms(100);output_low(pin_B2);for(i=0;i<8;i++){value=SPI_XFER(RFID, 0x32);printf(“Informacao: %cnr”,value);//value = spi_xfer(RFID, 0b10000000);}printf(“Geral: %cnr”,value);output_high(pin_B2);output_low(pin_C2);delay_ms(300);}}I tried a lot of BAUD RATE, change the pins of MISO and MOSI. I did all things but nothing happen.Can someone help me? It is a final project.September 1, 2014 at 4:02 am #12101AJISH ALFREDParticipantHi,
“Today I have connected using serial, just to send de computer information”, How you did this exactly?
September 1, 2014 at 10:57 am #12109EversonParticipantHi.
I´m using the MAX232 to send information to PC.
I have already had hardware implemented on my protoboard, and I just used it to communicate. I know that I could use the USB of 18F4550.
Like you see on my code, there is a directive to using the serial.
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,stop=1,parity=N, bits =
What I would like is communicate the MF522 using SPI. But nothing happen.
Thanks for now.
September 4, 2014 at 11:31 am #12128EversonParticipantHi Friends.
Is there anyone that can help me?
I don’t know if can be the module that uses 3.3v or the PIC that use 5v.
Maybe I need to put the MISO of module in RX of MAX232 to do the conversion of 3.3v to 5v.
Anyone has some idea to do it?
Thanks.
September 15, 2014 at 5:06 am #12181AJISH ALFREDParticipantYa, that voltage difference need to be taken care of. The max232 is no the right device for this. There are 3v – 5v bidirectional level shifter ics and modules available.
September 15, 2014 at 5:08 am #12182AJISH ALFREDParticipantThis project
http://www.engineersgarage.com/embedded/avr-microcontroller-projects/sd-card-interfacing-project
mention such a device.
-
AuthorPosts
- You must be logged in to reply to this topic.