USART Stops Receiving Characters


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2006
    Posts
    12

    Default USART Stops Receiving Characters

    Hi,

    Im having a problem where the usart sucessfully receives characters for a few seconds, each time sending a response, however inevitably stops receiving characters after a while (Interrupt is not triggered, and RCIF doesn't get set). I have set DEFINE HSER_CLROERR 1. The PIC is connected to the computer via a wireless serial link using an XBee, should the 3.3v serial ouput from this module be cause for concern? If I connect the Tx and Rx lines together I get everything i send echo'd back. There is <5mA ripple on the serial and power supply lines. Any ideas?

    Edit: Might also be worth noting that the PIC continues to run, for instance it can still HSEROUT while not receiving any serial input.

    Edit2: It appears not to stop receiving characters if the oscilloscope probe is connected, does that sound right? It is listed as a 10MOhm, 33pF probe.

    Regards,
    Daniel
    Last edited by breesy; - 25th November 2006 at 12:07.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Any scheme to post here?
    PIC #
    Osc Type and speed, crystal
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default

    Quote Originally Posted by mister_e
    Any scheme to post here?
    PIC #
    Osc Type and speed, crystal


    It is good to see that it is not only me still using traditional ways, even very ancient ways, to find answers.

    But Steve, may be your CrystalBall have limited data base.

    I use the Genie in the picture and I get anything I ask her!
    The bad thing is that I can only ask three questions per weekend!



    ----------------------------------
    Attached Images Attached Images  
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    time for a change

    Just ask here to have more than 3/week... it's still a wish
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jun 2006
    Posts
    12

    Default

    PIC18F2525 running at 20Mhz with a ceramic resonator.

    The Rx line is fed directly from the XBee Tx, Tx (if relevent) goes through a voltage divider to give 3.3v input to the XBee..

    Initialisation:

    DEFINE OSC 20

    ' ---- Setup Hardware for USART ----
    DEFINE HSER_BAUD 9600
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_CLROERR 1

    ' ---- Setup Hardware for ADC ----
    DEFINE ADC_BITS 8 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 20 ' Set sampling time in microseconds

    INCLUDE "variables.bas" 'Define Variables

    ' ---- Initialisation ----
    Init:
    Pause 10 'Safe Start Up Delay

    ADCON1 = 14 ' All pins are digital, except AN0 (RA0)
    CMCON = 7 ' Turn off comparators
    INTCON2.7 = 1 ' Turn off PORT B pull ups

    'Timer 0 is used for Input Pulse Measurement
    TMR0L = 0 'clear Timer 0 low byte
    T0CON = %11000101 'prescale = /64
    INTCON.5 = 0 'disable TMR0 interrupt

    'Timer 1 is used for the internal game clock
    T1CON.4 = 1
    T1CON.5 = 1 '8 prescaler
    TMR1ON = 0 'Stop the timer, enable once game running

    'Timer 2 is used for HPWM, is it really?

    Init_Ports:
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000

    PORTA = %00000000
    PORTB = %00000000
    PORTC = %00000000

    Input Rx
    Output Tx

    Input Serial_In
    Input Menu
    Input Battery
    Input Mercury

    'No PWM output when pin is input
    Input Backlight
    HPWM 1,50,40000

    Output Serial_Out
    Low Serial_Out
    Init_Proceedure:

    For i = 0 To 200
    Pause 1
    Next i

    GoSub Update_LED
    GoSub Update_LCD

    HSEROUT ["+"]

    Init_Interrupts:
    RCIE = 1 'Enable USART Rx Interrupt
    TMR1IE = 1 'Enable Timer 1 Interrupt
    INTCON2.6 = 0 'INT0 on Falling Edge
    INTCON = %11010000 'Global, Peripheral, INT0 Enable

    ON Interrupt Goto Interrupt_Handler

    Main_Loop:

    If Menu Then
    Input Backlight
    Else
    Output Backlight
    EndIf

    'Motion, Report If Requested.
    If (Report_Mercury = 1) AND (Status_Mercury <> Mercury) Then
    Report_Mercury = 0
    Status_Mercury = Mercury

    HSEROUT ["F"]
    EndIf

    Goto Main_Loop


    Interrupt:

    ' ---- Interrupts ----

    DISABLE

    Interrupt_Handler:
    If RCIF Then Goto Int_Rx
    If INT0IF Then Goto Int_Hit
    If TMR1IF Then Goto Int_Time

    Interrupt_Exit:
    INT0IF = 0
    While RCIF
    t = RCREG ' trash leftovers to clear RCIF before return
    Wend
    RESUME

    '-------

    Int_Rx:
    If RCSTA.1 Then
    HSEROUT ["Overrun"]
    Pause 6
    EndIf

    HSERIN 1, Interrupt_Exit, [PacketID, PacketCheckSum, str Buffer\20\Sentinel]
    CheckSum = 0

    If PacketID > 0 Then
    For i = 0 To 20
    CheckSum = CheckSum + Buffer[i]
    Next i
    EndIf

    If (PacketID > 0) AND (PacketCheckSum != (255 - CheckSum)) Then 'Failed To Receive Correctly
    HSEROUT ["\", PacketID]
    Pause 6
    Else
    Select Case Buffer[0]
    'Do Stuff
    End Select

    Pause 6
    HSEROUT ["/", PacketID]
    Pause 6
    EndIf


    Goto Interrupt_Exit
    Last edited by breesy; - 26th November 2006 at 01:26.

  6. #6
    Join Date
    Feb 2003
    Posts
    432

    Default

    Does it work if you remove the wireless link and have a direct cable connection?

    If not then there is a code problem with the PIC

    If it works then for some reason the radio link is dying.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default Missing include

    Quote Originally Posted by breesy
    PIC18F2525 running at 20Mhz with a ceramic resonator.


    INCLUDE "variables.bas" 'Define Variables

    Hi Breezy,
    no one can compile without variables.bas
    JS

  8. #8
    Join Date
    Jun 2006
    Posts
    12

    Default

    Hi,

    Problem solved with addition of 33pF cap between the line and ground..

    I am at a loss to explain why... Could there have been a high frequency ripple that I could not see on the scope since the probe is arresting it?

Similar Threads

  1. Receiving Packet Array In Usart
    By crhomberg in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 24th April 2007, 21:41
  2. Receiving Packet Array In Usart
    By crhomberg in forum Serial
    Replies: 1
    Last Post: - 18th April 2007, 23:31
  3. I2CRead and USART interrupt
    By HenrikBuhl in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th January 2007, 14:04
  4. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 18:56
  5. USART Problem Receiving Bytes
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th September 2005, 18:50

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