No announcement yet.

SystemReset() Question

  • Filter
  • Time
  • Show
Clear All
new posts

  • SystemReset() Question

    Using uVGAII, PMMC REV 25
    Using buffered comms
    Is executing a SystemReset() EXACTLY like performing a cold boot (ie global variable initialization, etc)? If I reboot using SystemReset (), I am seeing some bytes "stuck" in the com1 buffer, until more bytes come in.
    It's hard to explain, but it's as if the com1 count is zero, but the message buffer actually still holds some of the last message. In my main loop, I am constantly polling for the com1 count. If the count > 0, then I pass the number of bytes received to my message state machine. (It's not as inefficient as it sounds, as all we are doing is displaying incoming messages). My state machine process the bytes, and (when in debug mode) prints the current message state and message byte count.
    Bytes becoming "stuck" ONLY happens after a SystemReset. If I power off and on, I never see this happen. Also, it seems that it is ALWAYS 3 bytes that get "stuck".
    Keep in mind that I SEE every message that I send (I'm not "losing" bytes). But once I do a SystemReset, the first message does not "complete" until I send the second message, then the stuck bytes are processed in the state machine. The second message does not complete until I send the third message, etc
    Best Regards,

  • #2

    During a reset, the COM porst are reconfigured and memory is cleared, but there is a chance that the UART will gather some rubbish during reset, and when buffered
    comms is establised, the rubbish is being transferred to the buffer.

    Try adding this to your code prior to setting up the buffered comms to see if it fixes it:

    while(serin() >= 0);


    • #3

      Thanks Dave!
      That appears to have fixed it...... I can now do a remote reset and not have stuck bytes......
      Com init routine now looks like:
      func InitComPort() while(serin1() >= 0); //Empty out any pending bytes at port repeat com_SetBaud(COM1,960); //Set baud rate to 9600 com1_Init(rx_buf,RX_BUF_SIZE,0); //Set the comms RX buffer nbPause(5); //Non-blocking pause for 5 ms to see if any com errors occur until (!com1_Error()); //Keep retrying until no more errors HandleRxBytes.rx_state := S_IDLE; //Since we reset the com buffer, we should discard any messages we were buildingendfunc
      Best Regards,