I’m trying to use the B-G431B-ESC1 with a MA730 sensor (TBMA730-Q-LT-01A)
I remapped UART2 to UART1 on pins
WEAK const PinMap PinMap_UART_TX[] = {
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
WEAK const PinMap PinMap_UART_RX[] = {
{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
I changed the SPI pins as follows:
WEAK const PinMap PinMap_SPI_MOSI[] = {
{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
WEAK const PinMap PinMap_SPI_MISO[] = {
{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
WEAK const PinMap PinMap_SPI_SCLK[] = {
{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
WEAK const PinMap PinMap_SPI_SSEL[] = {
{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
I’ve reviewed the approaches listed here:
https://community.simplefoc.com/t/b-g431b-esc1-beginner-guide-i2c-guide/
When I tried to use the BEMF GPIO pin, the serial output wasn’t right and didn’t change even if I disconnected the sensor. I tried setting the BEMF outputs low and that didn’t make a difference For that reason, I used PC11 instead.
Using the pins listed above, the serial output is always 0.00 (even when I move a magnet near it) but does change if I remove power from the sensor.
I’ve tried quite a few different code approaches such as:
-
MagneticSensorSPI
class: MagneticSensorSPI sensor = MagneticSensorSPI(SSEL) - MA730-specific driver: MagneticSensorMA730 sensor(PA15)
- Using SPI.set with SPI.begin to set the SPI Pins
- Using SPIClass SPI_3(PB5, PC11, PB3); to set the SPI Bus
- Using sensor.init(&SPI_3); to initialize the sensor on SPI3
I did notice a few inconsistencies such as:
- The MA730-specific driver page says to use: sensor1.init(SPI2); that returns an error. Instead sensor1.init(&SPI_2) appears to be the correct format.
- The MA730-specific driver page says to use: MagneticSensorMA730 sensor1(SENSOR1_CS, true, mySPISettings); that returns an error because of the “true, mySPISettings” sections. I’ve only been able to run it with “true, mySPISettings” omitted.
- MagneticSensorSPIConfig_s doesn’t appear to be compatible with the MagneticSensorSPI sensor when using MA730_SPI. It’s not clear whether that is intentional or not.
- The MA730-specific driver page says that it gives access to the other registers of the MA730 but the “Here’s how you can use it” section doesn’t provide any examples of how to set the registers.
Any support or guidance would be very much appreciated.