PDA

View Full Version : Problems with HSERIN HSEROUT



Pesticida
- 19th September 2005, 19:11
Hi,
I have a little problem with my little codes.I push the buttons but dont receive data to PC ,but when i send data from PC to PIC 16F870 I receive data back,this is OK.This just happen when I put the codes together in Main:
But When I live just the Buttons code in Main then data are incoming to PC.
I think I can not use together RCIF and Buttons,I have a 4 Mhz Crystal and Max 232N.

Define LOADER_USED 1

Include "modedefs.bas" ' Mode definitions for Serout
DEFINE OSC 4
DEFINE HSER_RCSTA 90h ' Set receive status and control
DEFINE HSER_TXSTA 24h ' Set transmit status and control + BRGH=1
Define HSER_BAUD 9600
DEFINE HSER_CLROERR 1
ADCON1 = 7

A0 var byte
A1 var byte
A2 var byte
A3 var byte

' Alias definition
' ================
'
'
RCIF VAR portc.7 ' Receive interrupt flag (1=full , 0=empty)
TXIF VAR portc.6 ' Transmit interrupt flag (1=empty, 0=full)

' Variable definition
' ===================
'
'
SerialData var byte
' Hardware initialisation
' =======================
'
'
pause 10 ' safe start-up delay
Main:
if RCIF then ' incomming data?
hserin [Serialdata] ' take it ' I think here is the problem
hserout [Serialdata] ' send it
endif
BUTTON PORTA.0,0,255,1,A0,1,ML1
BUTTON PORTA.1,1,255,0,A1,1,ML2
BUTTON PORTA.2,1,255,0,A2,1,ML3 ' Or here I can not use all this
BUTTON PORTA.3,1,255,0,A3,1,ML4 together
goto Main


ML1:
Hserout ["M1"]
goto main

ML2:
Hserout ["M2"]
goto main

ML3:
Hserout ["M3"]
goto main

ML4:
Hserout ["M4"]
goto main
End


Please I need Help.
Thanks a lot
bye Pesti

Darrel Taylor
- 20th September 2005, 02:03
Hi Pesti,

The RCIF bit is in the PIR1 register. Not the RX pin itself.

<pre>RCIF VAR PIR1.5<br>TXIF VAR PIR1.4</pre>

Pesticida
- 20th September 2005, 17:24
Thanks a lot Darrel,now is working!!!
Have a nice day !

Pesti