2024-12-10 03:16 AM - edited 2024-12-10 10:50 PM
Hi,
We are trying to solve some problems regarding our SPI bus (bus stability, due to multiple branches in noisy environments) and reduce costs by eliminating a SPI sensor and make our STM8 to read a NTC. We would like the system to answer as the old SPI sensor, so we want to connect its CS to the STM8. The STM8 already had its own CS, so now it has two CS pins and we need it to answer to both of them. Is there a way to make this work?
Thanks in advance!
EDIT:
Attached you can find the schematic diagram of what I am trying to do. Basically we had a branched SPI bus (the master device can host up to 4 slave modules, each one has again a division of the SPI bus in two branches). We are eliminating the second branching, so there is only four branches with no extra division. The STM8 now has to read the NTC, extract the temperature and answer to the commands that were meant to be sent to the old temp sensor. We are trying to implement this in order not to change the FW in old master devices, so the new modules can be compatible with old host devices without upgrading them.
Solved! Go to Solution.
2024-12-12 07:59 AM
As far as I can see, CS_1 previously selected the temperature sensor so that you could read its temperature, right?
Now you want to signal to the STM8 instead that it performs a temperature measurement with the NTC when CS_1 is active?
Well, this is relatively easy to do by using the software NSS management with SSM=1 (see RM0016, section 20.3). In this case, the SPI module is not controlled with the hardware NSS pin, but via the bit SSI (SPI_CR2). Now you only have to realise a logic that e.g:
This is only a suggestion, of course you can still intercept errors if, for example, the second CS is subsequently activated although the previously started SPI action of the first CS has not yet been completed.
Hope that helps?
Regards
/Peter
2024-12-10 09:12 AM
Welcome @ManuelGomez_Opt, to the community!
Can you describe it in such a way that it can be understood?
Perhaps add extracts from the schematics, i.e. before and how it should look afterwards, because a drawing says more, rather than long explanations?
Regards
/Peter
2024-12-10 10:43 PM
Hi Peter,
I modified the original post in order to attach the diagram of what I am trying to do.
Regards,
Manuel
2024-12-12 07:59 AM
As far as I can see, CS_1 previously selected the temperature sensor so that you could read its temperature, right?
Now you want to signal to the STM8 instead that it performs a temperature measurement with the NTC when CS_1 is active?
Well, this is relatively easy to do by using the software NSS management with SSM=1 (see RM0016, section 20.3). In this case, the SPI module is not controlled with the hardware NSS pin, but via the bit SSI (SPI_CR2). Now you only have to realise a logic that e.g:
This is only a suggestion, of course you can still intercept errors if, for example, the second CS is subsequently activated although the previously started SPI action of the first CS has not yet been completed.
Hope that helps?
Regards
/Peter
2024-12-12 10:38 PM
Hello Peter,
Many thanks for your detailed answer, I think this is just what we needed. We will see if we can manage to make this solution to work and implement it for the final product.
Best regards,
Manuel