Shop OBEX P1 Docs P2 Docs Learn Events
Uart Break in C, works, but how? — Parallax Forums

Uart Break in C, works, but how?

Clock LoopClock Loop Posts: 2,069
edited 2020-09-03 18:00 in Propeller 1
Heres the c code that works to send a UART break.

I don't see how its doing that.

#include "wifi.h"


int main()
{
  wifi_start(31, 30, 115200, WX_ALL_COM);
}


I don't see what wifi_start is doing that generates a UART break.

Chasing down c code is like Alice tumbling down the rabbit hole.

I am simply trying to do the same in SPIN.

Comments

  • Here is the code for wifi_start function. You can see how the break is generated:
    fdserial *wifi_start(int fromDO, int toDI, int baud, int comSelect)
    { 
      #ifdef WIFI_DEBUG
      print("wifi_start\r");
      #endif  //WIFI_DEBUG
      
      wifi_buf = wifi_bufferSize(wifi_buf_size);
    
      wifi_pin_do = fromDO;
      wifi_pin_di = toDI;
      wifi_baud = baud;
      wifi_comSelect = comSelect;
      
      if(comSelect == USB_PGM) 
      {
        simpleterm_fromTxDo = fromDO;
        simpleterm_toRxDi = toDI;
      }    
      
      wifi_simpletermSuspend();
      
      wifi_fds = fdserial_open(wifi_pin_do, wifi_pin_di, 0b0100, wifi_baud);
     
      // Break condition
      pause(10);
      low(wifi_pin_di);
      pause(1);
      input(wifi_pin_di);
      pause(1);
      
      wifi_simpletermResume();
      
      return wifi_fds;
    }
    

    Mike
  • Clock LoopClock Loop Posts: 2,069
    edited 2020-09-03 18:22
    Ok, after luckily searching the 32420-Parallax-Wi-Fi-Module-API-v1.0, it says this:
    3. Via a Break Condition on the Serial interface itself
              a. Set the DI pin low for ≥ 30/baud rate,    seconds.
    

    Lol, I was attempting to do this and searching the net, these forums etc, for the word break, and those .h files...
    I was looking for 1 hour, and didn't even think to search the api... GAH.. time for a outdoor humming bird viewing break.

    SCREEEENS ARE ZOMBIFING ME....


    This works to generate a break to the WX module.
    Thats why the spin WX code wasn't working.
      dira[WXDI]~~          ' Set direction to output                        
      outa[WXDI]     := 0 
    
      waitcnt(80_000_000 + cnt)    'wait one second.
                                   
      FDS.start(WXDO,WXDI,0,115200)   ' Prop rxpin, Prop txpin, mode,baudrate  
    
    

    DEBUG output from WX debug pin.
    UART break detected. Switching on SSCP command parsing.
    

    YAAAY!

    *moves notch one up. only 1 million more to go...
  • iseries wrote: »
    Here is the code for wifi_start function. You can see how the break is generated:

    LOL, I still don't see where it puts the DI pin low for a bit in that c code.

    Gah, I don't like C... I do like spin.
  • Scroll down to where is says "Break Condition". It sets the pin low for 5 milliseconds.

    I hate spin but love C.

    Mike


  • Clock LoopClock Loop Posts: 2,069
    edited 2020-09-03 18:40
    Hah, I was searching all the .h files that are listed as INCLUDE. I did not search any .c file...
    Until you told me that. I didn't look in the .c file because it wasn't a #include.
    I clearly don't know enough about c to C. (see)
  • Right, the include files are usually not code but definitions.

    Mike
Sign In or Register to comment.