[SOLVED] RS485 node with STM32



  • I try to get a node based on STM32 to work with RS485. No success. Mysensors does send on RS485, but does not receive anything. I checked the signals with scope. Physically TX signals go out and reply from gateway goes into RX pin, but is not read by mysensors lib. I tried all UARTs. Apart from mysensors lib, I'm able to do serial communication with other UARTs than the one used for RS485.
    I used F103 and F401/411 with both STM libs (maple, ST) when possible.

    If I just change the ST chip to AVR it works instantly. So network and GW are not the issue.

    Any suggestions what to measure/change?

    Node:

    898097 TSM:FAIL:RE-INIT
    898097 TSM:INIT
    900098 THA:INIT
    900098 TSM:INIT:TSP OK
    900098 TSM:INIT:STATID=100
    900100 THA:SAD:ADDR=100
    900101 TSF:SID:OK,ID=100
    900102 TSM:FPAR
    900102 THA:SND:MSG=6464FF020307FF
    900133 THA:SND:MSG LEN=7,RES=1
    900133 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    904134 !TSM:FPAR:NO REPLY
    904134 TSM:FPAR
    904134 THA:SND:MSG=6464FF020307FF
    904153 THA:SND:MSG LEN=7,RES=1
    904153 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    908153 !TSM:FPAR:NO REPLY
    908153 TSM:FPAR
    908153 THA:SND:MSG=6464FF020307FF
    908172 THA:SND:MSG LEN=7,RES=1
    908172 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    912173 !TSM:FPAR:NO REPLY
    912173 TSM:FPAR
    912173 THA:SND:MSG=6464FF020307FF
    912191 THA:SND:MSG LEN=7,RES=1
    912192 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    916192 !TSM:FPAR:FAIL
    916192 TSM:FAIL:CNT=7
    916192 TSM:FAIL:DIS
    916193 TSF:TDI:TSL
    

    gateway

    0;255;3;0;9;26409142 TSF:MSG:READ,100-100-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;26409149 TSF:MSG:BC
    0;255;3;0;9;26409152 TSF:MSG:FPAR REQ,ID=100
    0;255;3;0;9;26409155 TSF:PNG:SEND,TO=0
    0;255;3;0;9;26409159 TSF:CKU:OK
    0;255;3;0;9;26409162 TSF:MSG:GWL OK
    0;255;3;0;9;26409388 TSF:MSG:SEND,0-0-100-100,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;26413162 TSF:MSG:READ,100-100-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;26413168 TSF:MSG:BC
    0;255;3;0;9;26413171 TSF:MSG:FPAR REQ,ID=100
    0;255;3;0;9;26413175 TSF:CKU:OK,FCTRL
    0;255;3;0;9;26413178 TSF:MSG:GWL OK
    0;255;3;0;9;26413325 TSF:MSG:SEND,0-0-100-100,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;26417182 TSF:MSG:READ,100-100-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;26417188 TSF:MSG:BC
    0;255;3;0;9;26417191 TSF:MSG:FPAR REQ,ID=100
    0;255;3;0;9;26417196 TSF:CKU:OK,FCTRL
    0;255;3;0;9;26417199 TSF:MSG:GWL OK
    0;255;3;0;9;26417269 TSF:MSG:SEND,0-0-100-100,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;26421201 TSF:MSG:READ,100-100-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;26421209 TSF:MSG:BC
    0;255;3;0;9;26421211 TSF:MSG:FPAR REQ,ID=100
    0;255;3;0;9;26421215 TSF:CKU:OK,FCTRL
    0;255;3;0;9;26421219 TSF:MSG:GWL OK
    0;255;3;0;9;26422238 TSF:MSG:SEND,0-0-100-100,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    


  • @karlheinz2000 Unfortunately there are no debug messages in the RS485 driver code available. I mean something similar to MY_DEBUG_VERBOSE_RF24 for the RF24 transport.

    When you don't get any input at the STM32 side I would start by adding some "Serial.println(x)" into the function _serialProcess() in ~\MySensors\hal\transport\RS485\MyTransportRS485.cpp
    to check if there is something coming in at least.

    HTH



  • @virtualmkr thanks for pointing to _serialProcess(). This help to understand a little more how it works.
    I finally found the issue: bias resistors (10k) at A and B lost connection, so during bus idle RX was low and not high. For AVR this was not a problem, but STM32 did not synchronize right to the frame.



  • @karlheinz2000 sounds great that you found the bug. It's always difficult to tell if it is a HW or SW bug on MCUs. From your first description it seems like a SW one to me.


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 10
  • 6
  • 3
  • 2

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts