HSEROUT & Sleep Question


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127

    Default HSEROUT & Sleep Question

    I have some code that sends commands via hardware serial port from one 18F14K50 to another. Due to UHF EMI (it's a UHF transmitter application) I need to put the master PIC into nap or sleep mode immediately after sending the command as you can actually hear the master's audio signature over the UHF's transmitted audio stream if it's in normal power mode (go figure).
    Anyway... The problem I have is when I place a sleep or nap command immediately after the HSEROUT, it doesn't appear to send the serial command or at least, not all of the serial command ie. it's likely missing the terminating character of the command thereby the slave processor isn't registering the command.
    If I replace the sleep or nap commands with pause or place a small pause between the HSEROUT & Nap/Sleep commands, it appears to work ok.
    So any ideas as to what is going on here?

    Thanks,

    Troy

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HSEROUT & Sleep Question

    You need to wait until the USART has finished sending all the bits before going to sleep.

    The TRMT bit (TXSTA.1) reads 0 (TSR full) while the USART is still shifting out data.
    Wait for it to go to 1 (TSR empty) before going back to sleep.

    Code:
    TRMT   VAR TXSTA.1
    
    HSEROUT ["Hello World!"]
    WHILE NOT TRMT : WEND
    @ SLEEP
    DT

  3. #3
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127

    Default Re: HSEROUT & Sleep Question

    Thanks Darren!

    Cheers,

    Troy

  4. #4
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127

    Default Re: HSEROUT & Sleep Question

    Thanks Darrel! (not Darren) [whacking forehead]

    Troy

Similar Threads

  1. Replies: 0
    Last Post: - 26th June 2010, 18:52
  2. Hserin & Hserout - Trying to blink an LED
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th May 2010, 13:25
  3. Sleep & nap
    By keymuu in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 4th December 2008, 19:45
  4. Replies: 5
    Last Post: - 5th February 2006, 17:51
  5. interupt & Sleep Problem - HELP!!
    By Santana in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd November 2004, 11:39

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts