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.

MFRC 531 + PIC 18F+ Parallel interface

Status
Not open for further replies.

jboud

Newbie level 6
Joined
Dec 25, 2008
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,355
mfrc531

Hi all,

I am working with pic 18F452 to control the mfrc531.

The oscillator that i am working with is 4*13.56 Mhz (i use PLL)

I am using parallel interface type:separated read/write strobe: multiplexed adress bus.

I multiplex add/data on port D

I have a problem in the START UP PHASE.

It's explained below this code.

unsigned char read (unsigned char add)

{ unsigned char val;

TRISD=0x00;

LATD=add; // Send address

LATC=0x20; //output_high(ALE)

LATC=0x00; //output_low(ALE)



TRISD=0xFF;

LATE=0x00; //output_low(NRD)

val=PORTD; // receive data

LATE=0x04; //output_high(NRD);

delay_us(3);

return val;
}



void reset()


{
delay_ms(500);
LATC=0x00; //output_low(RSTPD)
delay_ms (100);
LATC=0x10; //output_high(RSTPD)
delay_us (100);


read(RegCommand);


}

the problem is that val takes the address value which i sent previsiouly.
so i read the address value 0x01

I am loosing a much of time and i can't find the problem.

I would really appreciate receiving your help.

Cordially
 

Hi! Check that!

CHAR OpenRC(void) {
CHAR status = MI_OK;
MFRC_RST_IO = 0; // Set reset pin low
MFRC_RST_TRIS = 0; // Set reset pin as output
MFRC_INT_TRIS = 1; // Set interrupt input
MFRC_INT_EDGE = 1; // interrupt on raising edge
MFRC_INT_IP = 0; // low priority int.

CMCON = 0x07; // Turn comparators off
ADCON0 = 0x0F; // All digital IO
ADCON1 = 0x0F;

MFRC_NRD_IO = 1;
MFRC_NRD_TRIS = 0;
MFRC_NWR_IO = 1;
MFRC_NWR_TRIS = 0;
MFRC_ALE_IO = 0; // disable address select
MFRC_ALE_TRIS = 0; // Set ALE pin as an output
READER_INT_CLEAR;
return status;
}

///////////////////////////////////////////////////////////////////////////////
// Close Reader Communication
///////////////////////////////////////////////////////////////////////////////
void CloseRC(void) {
MFRC_NRD_IO = 1; // disable read
MFRC_NWR_IO = 1; //disable write
READER_INT_CLEAR; // clear interrupt
READER_INT_DISABLE; // disable interrupt
READER_RESET; // hold reader on reset
}

/* Select address */
void AddrSelRC(BYTE Address){
MFRC_LPT_IO = Address; // set address
MFRC_LPT_TRIS = 0x00; // set direction MFRC_LPT_IO as output
MFRC_ALE_IO = 1; // enable address select
Nop();
MFRC_ALE_IO = 0; // disable address select
}

/* Write one byte to the reader IC address space
* -o address (IN) reader ic register address
* -o value (IN) 8 bit value
* return: none
*
* This function determines the necessary page address of the
* reader module and writes the page number to the page
* register and the value to the specified address.
*/
void WriteRawRC(BYTE Address, BYTE value) {
AddrSelRC(Address); // Select address
MFRC_LPT_IO = value; // send data
MFRC_LPT_TRIS = 0x00; // set direction MFRC_LPT_IO as output
MFRC_NWR_IO = 0; // enable write
Nop();
MFRC_NWR_IO = 1; // disable write
}

/* Write one byte to the reader IC address space
* -o address (IN) reader IC register address
* return: value 8 bit data, read from the reader ic address space
*
* This function determines the necessary page address of the
* reader module and writes the page number to the page
* register and reads the value from the specified address.
*/
BYTE ReadRawRC(BYTE Address) { //RegPage=0x00
BYTE response;
AddrSelRC(Address); // Select address
MFRC_LPT_TRIS = 0xFF; // set input
MFRC_NRD_IO = 0; // set read
Nop();
response = MFRC_LPT_PORT;// get address file value
MFRC_NRD_IO = 1; // disable read
return response;
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top