This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use 2nd SPI interface
#1
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
Reply
#2
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.
Reply
#3
(2023-04-12, 03:40 PM)Sailoog Wrote: 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.

yes, that's my idea. My question was: What happens if 2 independent SW modules (OpenPlotter and my own one) try to use the SPI (the shared ports) at the same time? Does this create a problem?
Reply
#4
No problem you can do it.
Reply
#5
Wait, now you made me doubt. I remember using simultaneously both SPI channels of this board from 2 different instances of candump and cansend but now I realized that in fact both instances were just talking with a unique instance of socketcan which was in charge of read/write both channels.

I guess the only way to be sure is testing, please let us know your results.
Reply
#6
(2023-04-13, 11:55 AM)Sailoog Wrote: Wait, now you made me doubt. I remember using simultaneously both SPI channels of this board from 2 different instances of candump and cansend but now I realized that in fact both instances were just talking with a unique instance of socketcan which was in charge of read/write both channels.

I guess the only way to be sure is testing, please let us know your results.

ok, I will try to test it as soon as I can - however, these kind of 'race conditions' are always very hard to test.
Reply
#7
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.
Reply
#8
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.
Reply
#9
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
Reply
#10
thanks, please keep us updated, I will add your conclusions to the manual.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)