time for a change
Just ask here to have more than 3/week... it's still a wish![]()
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.
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 00:26.
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
Hi Breezy,Originally Posted by breesy
no one can compile without variables.bas
JS
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?
Bookmarks