Good evening Joe,
Thanks for this helpful tutorial, but I'm not really sure if I doing it right regarding the SERIN command...I tried to simulate it in Proteus software and no result...
Code:
@ device pic16F628A, INTRC_OSC_NOCLKOUT, wdt_on, mclr_on, lvp_off
Define OSC 4
CMCON = 7 ' PortA = digital I/O not quite, it means Comparators off.
VRCON = 0 ' A/D Voltage reference disabled
'"lets add this so PortA does not act like a radio antenna and create Ghost problems
PortA=0
TRISA=%00000111
TRISB = %11110000 'ports7:4 inputs, ports 3:0, outputs, is that what you want?
PortB = %00000000 ' Turn pins to low state Put this before TRISB so when PortB becomes all outputs they initialize in a state set by you, instead of chance
Led1 var byte ' Led1 as a byte(8 bits) variable
myvar var word ' myvar as a word(16 bits) variable
start:
include "modedefs.bas"
begin:
for myvar = 500 to 0 step - 25 ' 500 makes word variable necessary
high PortB.0
pause 100
low PortB.0
pause 100
high PortB.1
pause 100
low PortB.1
pause 100
high PortB.2
pause 100
low PortB.2
pause 100
'goto begin
next myvar
PortB = 0
main:
led1 = 4
loop:
'*******************************************************
serin portA.3,N9600,Led1
if Led1 = 0 then led1 = 1
if Led1 = 5 then led1 = 5
if Led1 = 7 then led1 = 7
if LED1 = 1 then high portb.0
if LED1 = 5 then high portB.1
if LED1 > 5 then high PortB.2
pause 1000
PortB = 0 ' this turns off the leds
goto loop
end
My question is, should I use RB1(TX) as input instead of PORTA.3, because I wanted to use the builtin USUART. and do I need to add any configuration to enable it?
Thanks in advance,
mbox
Bookmarks