If I understand you correctly, the PIC works correctly after pulling mclr low but not on power up . . . have you tried a capacitor from ground to mclr say 10uf to hold mclr low until pic gets going?Originally Posted by jrt4fun
If I understand you correctly, the PIC works correctly after pulling mclr low but not on power up . . . have you tried a capacitor from ground to mclr say 10uf to hold mclr low until pic gets going?Originally Posted by jrt4fun
Have you tried something as simple as:
PAUSE 50
FLUSH:
IF PIR1.5 = 1 THEN
HSERIN [FlushChar]
GOTO Flush
ENDIF
Main Program:
Charles Linquist
Hi guys,
Sorry for the late reply but here is the code:
@ DEVICE pic16F876A, HS_OSC
' System Clock Options
@ DEVICE pic16F876A, WDT_OFF
' Watchdog Timer
@ DEVICE pic16F876A, PWRT_ON
' Power-On Timer
@ DEVICE pic16F876A, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F876A, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F876A, CPD_OFF
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F876A, PROTECT_OFF
' Program Code Protection
' Set to PROTECT_OFF for Development Copy
' Set to PROTECT_ON for Release Copy
' Initial data for eeprom
DEFINE OSC 10
DEFINE I2C_SLOW 1
DEFINE HSER_RCSTA 90h ' enable serial port, enable continuous receive
define HSER_TXSTA 24h ' enable transmit, BRGH=1
define HSER_SPBRG 64 ' set baudrate to 9600
DEFINE HSER_CLROERR 1 ' automatic clear overrun error
SYNC con $AA ' Synchronisation byte 10101010 binary
RxD var PORTC.7 ' Rx data pin
RxTx var PORTC.5 ' Rx / Tx function
TxD var PORTC.6 ' Tx data pin
Blue var PORTA.0 ' Blue led
Red var PORTA.1 ' Red led
MyAddress var byte
Destination var byte
Source var byte
Data_1 var byte
Temp var byte
RCIF VAR PIR1.5
TXIF VAR PIR1.4
init: ADCON1=$07
TRISB=%00000000
PORTB=%00000000
Low RxTx ' Set to receive mode RS485
high Blue
For temp = 0 to 10 high red
pause 150
low red
pause 350
Next temp
low Blue
MyAddress = 200 ' init complete
loop: if RCIF then ' incomming data?
hserin [wait(SYNC),Destination,Source,Data_1]
high blue
if Destination <> MyAddress Then loop ' verify address
select case Data_1
case 1
gosub UnitOff
case 2
gosub UnitOn
end select
endif
goto loop
UnitOff:
Low blue
Return
UnitOn:
High blue
Return
End
strange, i'll bet on a hardware problem.... rrreeeaaalllyyy ssslllooowww start-up PSU maybe. BTW, do you have a complete schematic? if so, post it here.
Try adding a 10K pull-up resistor on the RX pin...
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks