PDA

View Full Version : Simple But Nothing



Michael
- 21st February 2006, 16:56
This has to be something basic I'm missing.

I'm at a loss as to why this RCVR doesn't function...I get nothing on the PORTB outputs. I can see the data from the transmitter which I have hardwired to the rcvr pic SERIN port A0. I can see the switches going on and off.

The transmitter is sensing switches on PORTA with 10k pulldowns to ground.
Input high = switch on (and rcvr portb high)

I'm using Micro code studio and have chosen the 16F628A.

Heres the code exactly...

PAUSE 2000

DEFINE OSC 4
INCLUDE "modedefs.bas"
CMCON = 7 'PORT A ALL I/O
TRISA = %11000001 'A0 IS SERIN A6 A7 XTAL
TRISB = %00000000 'ALL OUTPUTS

SWITCH VAR BYTE
QUALA VAR BYTE
QUALB VAR BYTE
SWITCH = 0
QUALA = %11001111
QUALB = %11010101

START:

SERIN PORTA.0,N1200,[QUALA,QUALB],SWITCH

PORTB.0 = SWITCH.0
PORTB.1 = SWITCH.1
PORTB.2 = SWITCH.2
(AND SO ON)

GOTO START

In the Epic software I have... 16F628A--XT--WDT on--PWRUP on--MCLR as
input--BROWN OUT on

Thanks kindly for your help.

Ron Marcus
- 21st February 2006, 19:53
This has to be something basic I'm missing.

I'm at a loss as to why this RCVR doesn't function...I get nothing on the PORTB outputs. I can see the data from the transmitter which I have hardwired to the rcvr pic SERIN port A0. I can see the switches going on and off.

The transmitter is sensing switches on PORTA with 10k pulldowns to ground.
Input high = switch on (and rcvr portb high)

I'm using Micro code studio and have chosen the 16F628A.

Heres the code exactly...

PAUSE 2000

DEFINE OSC 4
INCLUDE "modedefs.bas"
CMCON = 7 'PORT A ALL I/O
TRISA = %11000001 'A0 IS SERIN A6 A7 XTAL
TRISB = %00000000 'ALL OUTPUTS

SWITCH VAR BYTE
QUALA VAR BYTE
QUALB VAR BYTE
SWITCH = 0
QUALA = %11001111
QUALB = %11010101

START:

SERIN PORTA.0,N1200,[QUALA,QUALB],SWITCH

PORTB.0 = SWITCH.0
PORTB.1 = SWITCH.1
PORTB.2 = SWITCH.2
(AND SO ON)

GOTO START

In the Epic software I have... 16F628A--XT--WDT on--PWRUP on--MCLR as
input--BROWN OUT on

Thanks kindly for your help.

I believe you have to add a 'wait' statement for quala and qualb.

PORTB.0 = SWITCH.0
PORTB.1 = SWITCH.1
PORTB.2 = SWITCH.2

What is the above?
Is it supposed to be
'IF switch = 0 then
portb.0 = 1'
???

Michael
- 21st February 2006, 20:10
I have other software that works fine without a wait in it...that's not to say it "should be there".....learning is a neverending process with Picbasic because there are no decent learning guides.

IE...I just bought the Chuck Helebuyck book and it says nothing more than anything else I've read.

I could write it both ways....

if switch.0 = 1 then
portb.0 = 1
else
portb.0 =0
endif

BUT again, I have software I've written for the 16c65b that woks just fine
with...

portb.0 = switch.0

Ron Marcus
- 21st February 2006, 20:39
I still don't understand. The way you have it written, SWITCH is a variable you are getting from your SERIN routine?? So, I will assume that you are setting a bit on the transmit side on say...portb. Then you are reading portb, and sending it as a variable. On the receive side just make PORTB = SWITCH.

Now open the PBP manual and look up SERIN. There should be an example of a wait statement. If not, use SERIN2. Copy it verbatim and do not substitute "[" for "(" or vice versa. If you don't, don't be at a loss why it does not work. These things are fussy about syntax.

Ron

Michael
- 21st February 2006, 23:02
yes switch is a variable (switch contacts on xmtr)

like I say, the software as I have shown....

SHOULD WORK

why it doesn't has me perplexed.

switch or switch.0 same thing....may be redundant but that's not what I need to know.

BobK
- 22nd February 2006, 03:22
Hi Michael,

I thought I had an idea but I didn't read enough of the datasheet.

BobK

Michael
- 23rd February 2006, 17:10
Well, as it turns out, the code on this post was fine and it works with no problem. I don't want to seem like a bozo so I had to post the facts. As it turns out, it was the problems I was having with my new EPIC programmer and trying to install meprog.

I discussed it with Jeff at Melabs and he confirmed there has been "some" compatibility problems.

I spent 2 days trying to get meprog to work right and it's what I was using when I tried to program the code in this post.

EPICwin on the other hand is flawless and I can look forward to learning from all of you and enjoying these 16F628 chips that were recommended.

Sure beats the OTP parts.

FYI.