Problem in 5.1.5 28X compiler: pinsc & If

BDG

New Member
I have been writing code for 28X for many days with pinnsc (sucessfully) in code. Just after I wrote another 20 lines or so (mainly a Select Case Statement), I get a "Compile Error.. error in this line " (see >1>> below for position). I commented out the "& %00001111" bit just as a test, didn't help. The next Subroutine still has it as it once worked - it didn't like that either.

Code:
ReadDevice: ' 2 parameters required- AddrNib & DataNib
	Let outpins = AddrNib ' select device
>1>>	Let DataNib = pinsc '& %00001111  ' read back the low nibble
	Let outpins = 0 ' deselect device
Return

'------------------------------------------------------
ReadSwitch: ' 2 parameters required- AddrNib & DataNib
	Let outpins = AddrNib ' select device
	Let DataNib = pinsc & %00001111  ' read back the low nibble
	Let outpins = 0 ' deselect device
	Let DataNib = 255 - DataNib ' Logic for switches is upside down (active LOW with PUPs)
	Let DataNib = DataNib & %00001111
Return
If I comment out all references to reading from pinsc, it doesn't mind the "Let pinsc = xxx" but picks on the If statement (see >2>> below)

Code:
WriteDevice:  ' 2 parameters required- AddrNib, DataNib, DTMFDelay (0 for anything but DTMF Gen)
	Let outpins = AddrNib' select device
	let dirsc = %00001111 ' low nibble (Data Buss) as Inputs
	Let pinsc = DataNib ' send 4 bits to I/O pins as OP.
>2>>	If AddrNib = DTMFGen
		Pause DTMFDelay
	EndIf
	Let outpins = 0 ' deselect device
	let dirsc = %00000000 ' low nibble (Data Buss) as Inputs
Return
I suspect there is a problem somewhere, but compiler/editor isn't helping. How can I tell, and why is compiler complaining? There sounds like a bug in the compiler to if it can't see the real problem.

Additional Information:
I have just openned older files which once compiled (and loaded and ran) now giving me the same error at similar places (pinsc). I have restarted Editor, and can confirm it is set to 256 Gosubs (had a problem with this giving wierd errors previously).

Thanks,
Barrington
 
Last edited:

hippy

Ex-Staff (retired)
(1) Let DataNib = pinsc

The error is probably related to what "DataNib" is or how it has been defined using SYMBOL.

(2) If AddrNib = DTMFGen

A THEN at the end of the command will probably fix that one.
 

BDG

New Member
Hi Hippy, Thanks for replying.
Yes (2) is syntactily (is that a word or did make it up?) incorrect- fancy missing THAT! I could have sworn it didn't bring an error up when last compiled last?!

(1) however... Yes DataNib is deined correctly. In reading the documentation I don't think I can use pinsc in the context: Let DataNib = pinsc ....
All references to pinsc in the manual (2) shows pinsc on the writing side. E.g. Let pinsc = xxx; as an output. It looks like you have to use pins not pinsc when addressing as inputs. Tried this and it seems to compile. Now running tests to be sure.

Thnaks for taking the time to run a second eye over my code.
 

hippy

Ex-Staff (retired)
It looks like you have to use pins not pinsc when addressing as inputs.
You're right, and I hadn't appreciated that ( shows my lack of experience in using the 28X ), but we got there in the end !

On the 28X, Port C is the port for the default inputs and "=pins" reads the default input pins so "=pinsc" is unnecessary. One of the cases where a "Pinsc is not a valid variable for reading from" error message would have immediately highlighted the incorrect usage more so than "Mistake in this line".

Mind you, it could have been even more confusing for a 40X where Port C has to be read using "PEEK $87,var".
 

saunj

Senior Member
pinsc and pins on a 40X1

I am intrigued by "hippy"'s statement that port c on a 40X1 can be read by a PEEK (and presumably written by a poke) to specific addresses. Did I miss this in the documentation? I have been disappointed that LET commands do not work on port c: I have only been able to use HIGH, LOW and IF, so I have to use extra command to read and write these pins.

I also have been having a problem with the regular output port. Using pins = var, bit 7 = pin7 always comes out high. I have put in extra capacitors on Vdd to no avail. I have had to do a work-around and reset bit7 after the LET pins with a LOW.
 

Technical

Technical Support
Staff member
II have been disappointed that LET commands do not work on port c:
let pinsc = xxx

I also have been having a problem with the regular output port. Using pins = var, bit 7 = pin7 always comes out high. I have put in extra capacitors on Vdd to no avail. I have had to do a work-around and reset bit7 after the LET pins with a LOW.
Make sure you are using the latest version (5.1.5) of the software and the command:

let outpins = xxx
 

saunj

Senior Member
I am using 5.1.5. I meant individual portc pins, not the whole lot. Especially I would like to put the state of a given pin in an expression.

I tried outpins. Just the same. It's the same port.
 

hippy

Ex-Staff (retired)
One way to control individual Port C pins ( if HIGH PORTC / LOW PORTC are not suitable ) is to keep a separate variable which represents the pins, use bit masking, and then output that variable ...

- b0 = %00000000 ' All Low
- pinsc = b0
- b0 = b0 | %00000001 ' Set Port C Pin 1 High
- pinsc = b0
- b0 = b0 ^ %00000010 ' Toggle Port C Pin 2
- pinsc = b0
- b0 = b0 & %01111111 ' Set Port C Pin 7 Low
- pinsc = b0
 
Top