SPI Hal - Waiting to MISO line to be released

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

SPI Hal - Waiting to MISO line to be released

Postby akshaim » Thu May 12, 2022 1:08 pm

Hi Team,

I am trying to implement a driver using SPI for the ADBMS1818 chip which is used to measure the Cell voltages of battery cells. To start measuring the voltage using the ADC . I have to do a start poll operation (PLADC). After which I shall use another command to read the ADC values (say for eg : RDCVA).
When I ask the chip to start measuring ( PLADC) I have to wait for a specific amount of time depending on the number of cells being measured. The operation is shown in the image attached.

My doubt is with PLADC command. Is there a way to know when the request for conversion has been done based on the SDO line activity? I currently use spiStartExchange. Can `end_cb` in the SPI device descriptor be used for this purpose ?

Regards,

Akshai
Attachments
ADBMS1818.png

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Hal - Waiting to MISO line to be released

Postby Giovanni » Thu May 12, 2022 3:02 pm

Hi,

I think you could use GPIO (PAL driver) and poll for completion or to wait for a rising edge.

You could also keep doing spiReceive() until you get an 0xFF if the extra clocks are tolerated by the ADC.

Giovanni

akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

Re: SPI Hal - Waiting to MISO line to be released

Postby akshaim » Thu May 12, 2022 4:13 pm

Hi Giovanni,

Thank you for the reply. Unfortunately, I cannot wait as it will kill the timings. Is there a possibility for an asynchronous way to do it?

Regards,

Akshai

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Hal - Waiting to MISO line to be released

Postby Giovanni » Thu May 12, 2022 5:36 pm

Waiting for a rising edge is asynchronous, it triggers a callback. See PAL callbacks.

Giovanni

akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

Re: SPI Hal - Waiting to MISO line to be released

Postby akshaim » Thu May 12, 2022 6:28 pm

Thanks Giovanni. I shall explore that :)

Regards,

Akshai

akshaim
Posts: 20
Joined: Tue Sep 21, 2021 9:47 am
Has thanked: 9 times

Re: SPI Hal - Waiting to MISO line to be released

Postby akshaim » Tue Aug 16, 2022 10:50 am

Instead of polling via GPIO I ended up sending an empty requests using DMA and have callback check for `0xFF` in Rx buffer which shows the device is free :). This ended up being the easiest option


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 3 guests