PN7462 SPI Master Receive Interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PN7462 SPI Master Receive Interrupt

Jump to solution
2,440 Views
sanath_rai
Contributor III

Hello,

i am working on PN7462  NFC based Microcontroller.

I am using PNEV7462C development kit .

I need SPI master for one of my application.

i am able to transmit multiple data via MOSI to the slave device using the HAL driver function

but my issue is with Receiving data via MISO .

there is HAL function for it , but my application needs it in interrupt form, that is when i receive data  ISR for receive data should be called.

There is this  concept of water level interrupt which is bit confusing .Can any one help me to figure out the water level interrupts ? how can it be used for receive SPI data?

or

Are there any other way to receive SPI data via interrupts?

Regards,

Sanath Rai

Labels (2)
Tags (1)
1 Solution
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sanath Rai,

Please refer to the following for details.

pastedImage_1.png

Hope that helps,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

14 Replies
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hello Sanath Rai,

The API guide has details regarding this topic, please refer to the following for details.

pastedImage_1.png

and if the expected number of data is received or sent, the ISR will call the callback function as below:

pastedImage_2.png

you may put the data reception function in this callback, but we don't recommend doing that, as it might affect timing of other tasks, and if you insist on that, please keep the code as short as possible.

Hope that helps,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,033 Views
sanath_rai
Contributor III

Hello Kan_Li,

Thank you for the reply.

I am transmitting around 30 bytes of data through MOSI.While transmitting  i don't want the water level interrupt to be called.

I need the water level callback while i receive the data only.

In my case its hitting callback even when i am transmitting data.

say for Example i need to receive 6 bytes  ,below is the way i am testing the receive part of SPIM.

can you just validate it whether i am doing it right or wrong?

Step1: phhalSPIM_Init(PH_EXHIF_HW_SPIM_TIMEOUT);
Step2: phhalSPIM_Configure(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_MSB_FIRST, \
E_SPIM_MODE1, 0, \
0, PH_EXHIF_HW_SPIM_NSSPOL);

Step3: phhalSPIM_SetWaterLevel(6, Water_level _callback);     //6 Number of bytes i want to receive

Step4:  Water_level _callback(){

phhalSPIM_Receive(PH_EXHIF_HW_SPIM_SLAVE,PH_EXHIF_HW_SPIM_INIT_CRC,PH_EXHIF_HW_SPIM_CRC_INIT,6,rxspibuf,PH_EXHIF_HW_SPIM_CRC_OFFSET);

}

i am calling Receive function inside the water level callback function so that after i receive i can use the data for comparison and use in my application.

Is that the right way? 

In function phhalSPIM_SetWaterLevel,How to differentiate between number of bytes of data need to be transmitted and received? Are there separate settings for that?

Regards,

Sanath Rai

0 Kudos
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hello Sanath Rai,

Actually the callback is trigger when number of bytes are received or sent, so for your case, you need something to trigger the callback, though I am not sure the details of your application, just for instance, if there are 2 bytes sent out before 6 bytes  received, you should set the water level to 2 before calling phhalSPIM_Transmit(), and after 2 bytes sent out, the callback function will be triggered.

Hope that makes sense,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,033 Views
sanath_rai
Contributor III

Hello Kan_Li,

So you are saying if i want to receive 6 bytes i need to set water level to 6 bytes and then call phhalSPIM_Receive() in callback as i am doing in above code which i had posted.

In my application i will send the data out first but i will not receive data immediately it will come only from the slave occasionally or depends on the application from my slave side.

Regards,

Sanath Rai

0 Kudos
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sanath Rai,

If that is the case, water level can not be used for your application, does the slave side have any signal to notify the host start the read operation? like a GPIO toggling signal, which may be used as an interrupt signal, and you may put the SPI read code in the ISR instead.

Hope that makes sense,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,033 Views
sanath_rai
Contributor III

Hello Kan,

Sorry for the delayed reply.

That's a good suggestion i will give it a try and let you know.

Regards,

Sanath Rai

0 Kudos
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

That is ok, please kindly let me know if there is any issue.


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,033 Views
sanath_rai
Contributor III

Hello Kan,

Which document has the information about external interrupts of PN7462? and also are there any drivers written for external interrupts in example libraries?

so that i will use a GPIO pin for external interrupt to indicate the incoming  data from slave side.

Regards,

Sanath Rai

0 Kudos
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sanath Rai,

PN7462 has enough GPIO interrupt resources , please refer to the following for details. You also may refer to 8.6 I/O Pad Management in UM10858 for more details.

pastedImage_2.png

pastedImage_1.png

and you may find GPIO drivers in the hal folder as shown below:

pastedImage_3.png

Hope that helps,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,033 Views
sanath_rai
Contributor III

Hello Kan,

Thank you for the guidance.

i can configure the GPIO as external interrupts .but i could not find the callback(ISR) for it.

am i missing something.Or do i need to use PCR init and PCR call back function(phhalPcr_RegCallBack) for it?

below are the functions used for configuring

phStatus_t phhalPcr_ConfigInput();

phStatus_t phhalPcr_ConfigPuPd();

Regards,

Sanath Rai

 

0 Kudos
2,033 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sanath Rai,

Actually phhalPcr_GpioInit() is enough to setup the GPIOs, and it is done out of POR.

pastedImage_1.png

You may just modify the EEPROM configurations referring to UM10948

pastedImage_2.png

and GPIO ISRs are referred in phFlashBoot_VT.c.

pastedImage_3.png

You may define the ISR as others, for example, SPIM_IRQHandler().

pastedImage_4.png

Hope that helps,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,033 Views
sanath_rai
Contributor III

Hello Kan,

That's a Good function to Initialize the GPIO as input/output and as interrupts.

So i can initialize any of the GPIO's 1-12 as interrupt source using  phhalPcr_GpioInit() .I understood the  function.

But can you please elaborate on the configuration part InputISR[12] and OutputPUPD[12] .

i am bit confused there.Sorry for the trouble.

Thank You

Sanath Rai

.

0 Kudos
2,034 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Sanath Rai,

Please refer to the following for details.

pastedImage_1.png

Hope that helps,


Have a great day,
Kan

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,032 Views
sanath_rai
Contributor III

Hi Kan,

Thank you for the support.

I understood the configuration. I will work on it.

Thanks And regards,

Sanath Rai

0 Kudos