Author Topic: MPLAB Harmony V3 configuration to for SPI Slave  (Read 1300 times)

0 Members and 1 Guest are viewing this topic.

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
MPLAB Harmony V3 configuration to for SPI Slave
« on: June 06, 2021, 04:49:02 pm »
Hi,
I am using MPLAB Harmony V3 and when I place the SPI "block" in the project graph, I can configure SPI to be configured in slave mode or master mode.
But when I add the SPI Harmony driver block and connect it to the SPI peripheral block, it automatically changes the SPI peripheral block to master AND ALSO locks the peripheral block (grey it out) so you cannot change it back to Slave Mode.

1) Why? It does not make any sense...
2) How can I CONFIGURE and USE a full SPI Harmony driver in SLAVE mode?
3) I could not find any proper sample code using Harmony 3 (the various ones are using only the PLIB or have too simple code or use DMA which I do not want to). Where can I find some proper code for receiving data as a slave?

Thank you :)
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: MPLAB Harmony V3 configuration to for SPI Slave
« Reply #1 on: June 06, 2021, 05:04:04 pm »
"Driver" is a higher level interface with mutexes and request queue management.  It is designed more for RTOS use. For master mode, it is easy to implement, since you have multiple tasks trying to talk to multiple devices on the same bus. But for the slave, it is not so easy and not really necessary, since slave functionality typically represents once device to the outside masters.


You get all the APIs you need to work with the peripheral from the basic block, so just use that.

PLIBs is what you want here. I don't understand the "too simple" part. If it does what is necessary, then why it is bad that it is simple?
Alex
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
Re: MPLAB Harmony V3 configuration to for SPI Slave
« Reply #2 on: June 06, 2021, 06:15:04 pm »
Thank you Alex,
I am using freeRTOS, and it would make it easier to switch via software between master and slave (the hardware can be configured in multiple ways). That is why I was hoping to us the driver.

Are you saying that the Harmony Driver does not support at all the slave configuration?

Thank you :)
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: MPLAB Harmony V3 configuration to for SPI Slave
« Reply #3 on: June 06, 2021, 08:02:03 pm »
No. It is not clear what that would even do. The driver handles and dispatched requests like "read so many bytes from slave #1". But for the slave you need to have the data in advance or just in time, since you don't know when the master may ask for it. And in many places you need to react differently based on the first few bytes received (a command or address, for example) So driver like this would be mostly useless.


And dynamically switching between master and slave is also a pretty exotic requirement. So just stick with PLIBs, it would be much easier.
« Last Edit: June 06, 2021, 08:04:54 pm by ataradov »
Alex
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
Re: MPLAB Harmony V3 configuration to for SPI Slave
« Reply #4 on: June 06, 2021, 08:04:39 pm »
 :-DD yes, you are right, totally makes sense!!!

Thank you :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf