cancel
Showing results for 
Search instead for 
Did you mean: 

Hello Dear Sir SWMPI communication using STM32L476 between two microcontroller is not working.

RKuma.15
Associate II

Sub: Single wire communication is not working 

Dear Sir 

I developed Hw design and and now writing firmware for stm32L476 microcontroller. Requirement of project is Single wire communication. I chose STM32L476, the reason behind was single wire communication (SWMPI on Port B pin12) peripheral present in this microcontroller. I took Bit rate 100kBits/sec.I connected both boards using swmpi wire and ground pins. Problem is that single wire communication is not working. I am not able to receive data at receiver side board.

i used as below code snippet: 

To Initialize SWMPI 

 hswpmi1.Instance = SWPMI1;

 hswpmi1.Init.VoltageClass = SWPMI_VOLTAGE_CLASS_B;

 hswpmi1.Init.BitRate = 19;

 hswpmi1.Init.TxBufferingMode = SWPMI_TX_NO_SOFTWAREBUFFER;

 hswpmi1.Init.RxBufferingMode = SWPMI_RX_NO_SOFTWAREBUFFER;

i am using API for communication

Receiver Side microcontroller:

char tx_data_buf[32];

  while(1){

status = HAL_SWPMI_Receive(&hswpmi1,(uint32_t *)&obj_convrt.v, 1,100);

if(status== HAL_OK)

{

memset(tx_data_buf,0,32);

sprintf(&tx_data_buf[0],"<%x,%x,%x,%x>\n",   obj_convrt.b[0],obj_convrt.b[1], obj_convrt.b[2], obj_convrt.b[3]);

HAL_UART_Transmit_IT(&huart1,(uint8_t *)tx_data_buf,4);

}

Transmitter side Microcontroller:

uint32_t tx_swmpi_data = 0x12345678;

while(1){

 HAL_SWPMI_Transmit(&hswpmi1,(uint32_t *)&tx_swmpi_data,1,100);

 HAL_Delay(1000);

}

Please help in this regards . I have also attached hardware schematic snap shots 

4 REPLIES 4
RKuma.15
Associate II

Sub: Single wire communication is not working 

Dear Sir 

I developed Hw design and and now writing firmware for stm32L476 microcontroller. Requirement of project is Single wire communication. I chose STM32L476, the reason behind was single wire communication (SWMPI on Port B pin12) peripheral present in this microcontroller. I took Bit rate 100kBits/sec.I connected both boards using swmpi wire and ground pins. Problem is that single wire communication is not working. I am not able to receive data at receiver side board.

i used as below code snippet: 

To Initialize SWMPI 

 hswpmi1.Instance = SWPMI1;

 hswpmi1.Init.VoltageClass = SWPMI_VOLTAGE_CLASS_B;

 hswpmi1.Init.BitRate = 19;

 hswpmi1.Init.TxBufferingMode = SWPMI_TX_NO_SOFTWAREBUFFER;

 hswpmi1.Init.RxBufferingMode = SWPMI_RX_NO_SOFTWAREBUFFER;

i am using API for communication

Receiver Side microcontroller:

char tx_data_buf[32];

  while(1){

status = HAL_SWPMI_Receive(&hswpmi1,(uint32_t *)&obj_convrt.v, 1,100);

if(status== HAL_OK)

{

memset(tx_data_buf,0,32);

sprintf(&tx_data_buf[0],"<%x,%x,%x,%x>\n",   obj_convrt.b[0],obj_convrt.b[1], obj_convrt.b[2], obj_convrt.b[3]);

HAL_UART_Transmit_IT(&huart1,(uint8_t *)tx_data_buf,4);

}

Transmitter side Microcontroller:

uint32_t tx_swmpi_data = 0x12345678;

while(1){

 HAL_SWPMI_Transmit(&hswpmi1,(uint32_t *)&tx_swmpi_data,1,100);

 HAL_Delay(1000);

}

Please help in this regards . I have also attached hardware schematic snap shots 
_legacyfs_online_stmicro_images_0693W00000bihl8QAA.png
_legacyfs_online_stmicro_images_0693W00000bii1xQAA.png

Define "not working"

Perhaps use a scope or logic analyzer to review signals and contrast against expected signals.

Your UART transmit doesn't seem to output enough data

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RKuma.15
Associate II

Thanks for reply.

I am sending data one WORD size. with value 0x12345678 from one board as Transmitter unit ;

And Other MCU board Unit as Receiver to read data from SWMPI single wire communication.

But I got value as 0x00 00 00 00 , as four bytes. I also used Oscilloscope to view data pattern.

Perhaps try some of the examples, and test functionality of those, port to your platform

STM32Cube_FW_L4_V1.17.2\Projects\STM32L476G-EVAL\Examples\SWPMI\SWPMI_Session\Src\main.c

Find an FAE in your local sales office to discuss this with. Not sure there's much support of SWPMI here, or many with own hardware.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..