PDA

View Full Version : Pic - reset



jrt4fun
- 12th September 2006, 07:54
Hello,

I wrote a program where I'm collecting data using the internal uart of the Pic16F876A.
In my main loop I check the status of the RCIF flag. When the flag is set I'm collecting the data (8bytes).

All is working fine except when I do a 'cold reset' (power off/on) the data is to be sent twice before the pic executes the command.
However when I reset the pic by pulling the MCLR pin low the device is responding immediately.

Someone has a thought how this can be solved or did someone had the same experience?

Thank you

BigWumpus
- 12th September 2006, 21:42
Without any code....

I think you put the right baudrate after polling the RX-register !

mister_e
- 12th September 2006, 21:55
I guess the Power-Up Timer and the Brown-out Voltage config bit maybe TRIS, maybe this, maybe that.

Post your code here, even if we are close, we are not god :D

Archangel
- 13th September 2006, 00:09
All is working fine except when I do a 'cold reset' (power off/on) the data is to be sent twice before the pic executes the command.
However when I reset the pic by pulling the MCLR pin low the device is responding immediately.

Thank you
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?

Charles Linquis
- 13th September 2006, 01:43
Have you tried something as simple as:

PAUSE 50

FLUSH:

IF PIR1.5 = 1 THEN
HSERIN [FlushChar]
GOTO Flush
ENDIF

Main Program:

jrt4fun
- 14th September 2006, 10:46
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

mister_e
- 14th September 2006, 15:15
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...

mc sung
- 17th September 2006, 09:09
Without any code....

I think you put the right baudrate after polling the RX-register !
Hi.May i know how to connect the lcd display wif pic 16f877a ,include the schematics and the software.thanks n have a nice day.

Melanie
- 17th September 2006, 09:26
Schematics and code are already in the PICBasicPro manual. Just adjust it for your chosen PIC and the pins you want to use, taking into account that your PIC may have Comparators and ADCs that may need to be disabled if you chose to use those PIC pins that have them.

mc sung
- 19th September 2006, 19:12
Schematics and code are already in the PICBasicPro manual. Just adjust it for your chosen PIC and the pins you want to use, taking into account that your PIC may have Comparators and ADCs that may need to be disabled if you chose to use those PIC pins that have them.
Hi.Actually i m dummies for this software.Can u send me the examples code how to write a program to display a word in lcd using PIC.I really dun know where to get d examples code.Your helps really me appreciates.Thanks