View Full Version : USART Stops Receiving Characters
breesy
- 25th November 2006, 09:16
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
mister_e
- 25th November 2006, 14:16
Any scheme to post here?
PIC #
Osc Type and speed, crystal
<img src="http://www.mister-e.org/Pics/CrystalBall_Informations.gif">
sayzer
- 25th November 2006, 16:58
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!
----------------------------------
mister_e
- 25th November 2006, 17:55
time for a change :D
Just ask here to have more than 3/week... it's still a wish ;)
breesy
- 26th November 2006, 00:18
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:
<code>
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
</code>
Interrupt:
<code>
' ---- 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
</code>
keithdoxey
- 26th November 2006, 00:34
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.
Archangel
- 26th November 2006, 00:45
PIC18F2525 running at 20Mhz with a ceramic resonator.
INCLUDE "variables.bas" 'Define Variables
</code>
Hi Breezy,
no one can compile without variables.bas
JS
breesy
- 26th November 2006, 03:50
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?
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.