cancel
Showing results for 
Search instead for 
Did you mean: 

ST25R3916B Writing To Registers Bare Metal

cbarb2747
Associate III

For my setup, I am using a nucleo-L476RG and a NFC08A1.  I am wanting to learn bare metal programming to really grasp micro controller programming.  I have programmed some smaller bare metal programs, SPI, I2C, etc on the nucleo.  Now, I am trying to interface with the NFC08A1.  Looking at the ST25R3916B datasheet,

and reading through the SPI section I was a little confused by the read and write commands in the table 12 SPI operation modes. The other commands are pretty straight forward sending of bits.  Can someone help me understand what A5 - A0 represent?  I am thinking they are addresses to the different registers or referencing certain pins.  For instance, in Table 2 A5 is referencing the SPI enable pin.  In other areas of the data sheet for the SPI interface on Figure 16 SPI communication: writing multiple bytes it says write to the sclk falling edge data moved to address <A5-A0>.  Thanks in advance.

6 REPLIES 6
Brian TIDAL
ST Employee

Hi 

A bare metal driver of the ST25R3916B is available in the X-CUBE-NFC6 package. It is recommended to use it rather than re-developing a new driver.

Regarding your questions,

  • in table 2, A5 is the pin number of the BSS for a WLCSP36 package
  • in table 12, A5-A0 is the register address

Rgds

BT

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

It says in the datasheet for the ST25R3916B  that enabling the rx_en bit in the operation control register will put the board in Receiver mode

st25r3916b_Datasheet.png


So if I wanted to do thisthere would be two steps in writing to the Operation Control Register and turning the rx_en bit to 1,  correct?

Operation Control Register.png

First, I would do a write command where A5 - A0 is the address of the Operation Control Register, which is 02h, correct? 
So it would be write

M1    M2    C5  C4  C3  C2  C1 C0

0        0       0     0     0    0     1    0

then another write with the hex number 6 which enables shifts a bit (1<<6) to enable the rx_en bit correct?

M1    M2    C5  C4  C3  C2  C1 C0

0        0       0     0     0    1     1    0

Is my thinking correct?

SPI_Commands.png

Brian TIDAL
ST Employee

Hi,

if you want to write rx_en=1 into the Operation Control Register, just send 0b00000010 followed by 0b0100000. Basically you have to first read the current value, modify the bits you want to change (i.e. rx_en) and write back the value (Read/Modify/Write).

Again, I recommend you have a look into the X-CUBE-NFC6 package. This provides all the bare metal API to read/write register and the NFC communication stack.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks for the info.  I was digging a little in the package listed.  Do you know which file or folder I can find the code you speak of?

Brian TIDAL
ST Employee

Hi

For the driver part, I would suggest to have look into st25r3916.c and st25r3916_com.c files in \Drivers\BSP\Components\ST25R3916 folder of the X-CUBE-NFC6 package. For the NFC communication stack, this is in Middlewares\ST\rfal folder.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thank you so much for the direction.