Posts: 4
Threads: 1
Joined: Aug 2022
Reputation:
0
Hi,
I need a second SPI for my own ADC. This should be possible using e.g. GPIO8 as the CS signal. Since the first SPI is being used for the NMEA 2000 interface and controlled by the OpenPlotter SW stack will this collide with my own SW if both programs want to use SPI at the same time?
Thanks
Stefan
Posts: 2,836
Threads: 60
Joined: Mar 2016
Reputation:
267
No problem you can do it. MacArthur HAT uses SPI0 CE1 (GPIO7) for NMEA 2000. You should use SPI0 CE0 (GPIO8) for your device. The rest of the SPI pins can be shared by both interfaces.
Posts: 2,836
Threads: 60
Joined: Mar 2016
Reputation:
267
2023-04-12, 05:47 PM
(This post was last modified: 2023-04-12, 05:48 PM by Sailoog.)
No problem you can do it.
Posts: 2,836
Threads: 60
Joined: Mar 2016
Reputation:
267
Set one of them and If I am not wrong as soon as you try to connect the same serial port from the second script, it will start fighting for it and finally they both will stop working.
Posts: 4
Threads: 1
Joined: Aug 2022
Reputation:
0
still at home and not using a CAN bus. However, I tried it with a small test script reading even the same channel from multiple processes - and this seems to work. Unless Signal-K does something really weird I am confident it will work using both SPI channels.
Posts: 292
Threads: 4
Joined: Mar 2016
Reputation:
9
2023-04-18, 01:29 AM
(This post was last modified: 2023-04-18, 01:35 AM by holgerw.)
By using an own Interrupt line for every SPI Channel this INT will signal when the Chip-Register is ready to read (or write). But this Interrupt-SubRoutine so has to do it´s job as fast as possible. Their last line is an Return-from-INT. This enables all other Interrupts again. So maybe you need an little FirstIN-FirstOut-Buffer for every SPI-Channel if you can`t compute the received Data in this Time. The INT Routine has to be shorter to have an Chance to readout the other INT-Routines so they do not overflow from their own received Data.
Should be possible. But the INT Routines are not so easy to understand and develop. But if you get them to work correctly they do it in Background and with highest Priority and disturb nothing.
keep on. Holger
Posts: 2,836
Threads: 60
Joined: Mar 2016
Reputation:
267
thanks, please keep us updated, I will add your conclusions to the manual.