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.

Unable to read slave data.

Status
Not open for further replies.

ghoral

Newbie level 6
Joined
Apr 4, 2019
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
113
What does data[7:0] mean??

rfid.png

Here , What does DATA[7:0] mean, Do I have to send just (char DATA) to i2c_write function or it should be like (char DATA =0x00).
 
Last edited by a moderator:

Re: What does data[7:0] mean??

Hi,

Data[7:0]= 8 bits of data
* data7, data6, data5....data0.

Klaus
 

Re: What does data[7:0] mean??

So we just send char data= 0x00 or it should be any specific address.
 

Re: What does data[7:0] mean??

Hi,

Are you aware, the we don't know
* what controller you use
* what I2C device you use
* what compiler you use
* what libraries you use
...

Klaus
 

Re: What does data[7:0] mean??

Assuming that the I2C address indicates that you are doing a write to the device, then you should be putting in whatever value you need to send to that device address.
Susan
 

Re: What does data[7:0] mean??

I am using Avr atmega 32 and MFRC522 and atmel studoo.
 
Last edited by a moderator:

Hi,
I am doing project on RFID MFRC522. I have done read and write cycle according to datasheet page 20. I have send device address, and Fifo register address(0x09 datasheet page 36) and 8 bit data. I have done according to cycle But I cannot read the data. I dont know where I am getting ERROR. I think I have used right registers address and function are also ok.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#define F_CPU 16000000UL
#include <avr/io.h> 
#include <string.h>
#include <inttypes.h>
 
#define  SDA PC0
#define SCL PC1
 
#include "Lcd.avr.h"
#include "I2C.avr.h"
#include "i2cmaster.h"
//#include "Rfid.h"
 
#define Write_Address 0x50 //slave addres
 
#define Register_Address 0x09 //fifo register address
 
#define I2c_write 0 //write bit
#define I2c_read 1 //read bit
 
char Data=0x00; //Data[7:0]
 
void Rfid_Start()
{
    i2c_init();
    i2c_start(Write_Address+I2c_write);
    i2c_write(Register_Address);
    i2c_write(Data);
    i2c_stop();
}
unsigned char Rfid_get_data()
{
    
    i2c_start(Write_Address+I2c_write);
    i2c_write(Register_Address);;
    _delay_ms(1);
    i2c_start(Write_Address+I2C_READ);
    Data = i2c_readAck();
    i2c_stop();
    return Data;
}
 
int main()
{
    
    DDRB = 0xFF;
    lcd_init();
    _delay_ms(100);
    LCD_String_xy(0,0);
    lcdprint("Show your card:");
    Rfid_Start();
    
    while(1) 
    {
        Rfid_get_data();
        LCD_String_xy(0,1);
    //  PORTB = 0xFF;
        lcd_int(Data);
    
    }
}

 
Last edited by a moderator:

Hi,

I have no experience with your library functions. But from standard I2C communication:

Code:
unsigned char Rfid_get_data
    
    i2c_start(Write_Address+I2c_write);
    i2c_write(Register_Address);
    _delay_ms(1);
    i2c_start(Write_Address+I2C_READ); [COLOR="#FF0000"]--> here I expect I2C_repeated_start instead of I2C_start[/COLOR].
    Data = i2c_readAck();[COLOR="#FF0000"]--> here I expect to send a dummy byte 0xFF, then read the I2C_input_data_register[/COLOR].
Maybe your library functions do this correctly --> read the library documentation
Or look for verified code examples. I2C communication is almost independent from I2C_slave type, thus no need to look for a MFRC522 code.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top