40 input portc

senyabeb

New Member
trying to load portc as input to (say) b5

portc = b5 . compiles but don't work
if portc pin0=1 then .... goes ok

want to load all 8 bits of portc at once


anyone now how to load portc into a register ?



regards eric
 

westaust55

Moderator
First use the dirsc to set the required pins as inputs

Eg: dirsc = %00000000 ; set all 8 pins of port c to inputs

then for example,
Let b0 = pinsc

From that, bit0 will hold the state of portc pin 0, bit1 will hold the state of portc pin 1, etc
 

senyabeb

New Member
40 pin pic portc

Hi.
thanks for the reply

I've tried that , its ok with the new (28 pin) small surface mount pic
but I've a job with one of the old larger 40x pin pics. maybe the larger one can't support
b0=pinsc ?

ie

' to load portc

dirsc = % 00000000

let b0 = pinsc <= syntax error !!!!!



it don't compile highlights line 2 ..... syntax error ! ??

regards eric
 

westaust55

Moderator
Differences in Port C for 28X/X1 and 40X/X1 parts

The difference is that with the 28X/X1, that the “standard inputs as used by most commands such as serin are on port C and the same pins sare funcationality with signals such as PWM, hserin/out and the i2c plus SPI comms signals.

For the 40X/X1, those same “standard” inputs are on port B and now port C is a separate port which can act as simple IO but is the connections for those same PWM, hserin/out and the i2c plus SPI comms signals.
 

senyabeb

New Member
40X portc

Hello again



I have 12 ls373 transparent latches, 6 configured as input and six as o/p. bussed on portc
with an ls154 I can write to each o/p and i/p using portc with the 28pin sm chip (using
%0000000 and %11111111 etc. (using OE and monostable to CLK) 8bits at a time.

with the 40X can write 8bits to portc and read in from portc only on a pin at a time basis

I wanted to configure the 40X chip to read 8bits into portc

ie

'b5=pinsc


I must be stupid cos I still don't get it !

regards Eric
 

westaust55

Moderator
I think that it may not be possible. If someone has it working I am sure they will advise.

pinsc is not referenced in the manual in the way you are trying to use it.
With the 40X or 40X1, the commands

pins = the input port when reading from the port
outpins = the output port when writing to the port

pins = b0 or Outpins= b0 operates on (writes to) the output pins of Port B, and
B0 = pins operates on (reds from) the input pins of Port D
BUT, pinsc is always looking at the same port. (Port C) so I can see that it may not work.

While the logic in terms of which side of the “=” the word pinsc is on could work there are no examples in the manual for reading in from portc in the manner you want. Unfortunately I am not home at the moment to try it out.
 

BCJKiwi

Senior Member
As covered by others, careful reading of the manual and testing in the editor shows that portC on the 40X1 won't work the way you want - will do all the pinsc/dirsc things except the one you want.

Can you re-arrange which ports the connections are on to achieve the functionality?
You also have the option of checking each pin individually, and if necessary, creating a binary map in b5.
 

hippy

Technical Support
Staff member
Not tested but "PEEK $07,b0" should read Port C assuming it's configured for inputs.
 

senyabeb

New Member
40X_portc_ fixed

Fantastic!

config portc %00000000
then
peek $07,b5 works like a charm.... gets all 8bits into b5 !

Thanks very much . Love these picaxe's

eric
 

hippy

Technical Support
Staff member
The question seems to comes up often enough that it would be worth making the change to the compiler to generate the equivalent PEEK.
 
Last edited:

Technical

Technical Support
Staff member
We could add

readpinsc b1

as a new pseudo command, but could not add

let b1 = pinsc (maths var ) etc

as pinsc is not a 'true variable' that would work within let equations.

We will consider this for the next release.
 

hippy

Technical Support
Staff member
No reason "Let var = PINSC<cr><lf>" shouldn't be supported as far as I can see as it's just a special syntax case in the assignment parsing, unless there's something peculiar with the parsing engine.

In fact it would be possible to use PINSC as if it were a variable in expressions in most cases by detecting a reference to PINSC, prefixing a "PEEK $07,infra" and using 'infra' / 'keyvalue' as the actual PINSC variable. That it corrupts the 'infra' variable can be noted in the manual and only a small minority of people ( I'd say none ! ) would likely be using 'infra' and PINSC in the same expression. That way it would also be possible to have "IF PINSC = $xx THEN".

The same could apply to "LET var = outpins" rather than "READOUTPUTS var", but as I'm not having to do the work I would say "READPORTC var" would be an acceptable compromise and in line wth existing practice and convention.

I'd personally take the trick of using 'infra' ( or some other temporary variable ) to the next level and allow commands to be used as functions, for example ...

LET b0 = READADC(1)
LET b1 = PEEK($07) ^ $FF

When there's no following maths that can optimise to what the existing commands are, otherwise prefix that command using the temporary variable then use that in the rest of the maths. As with unary operators (NOT,DCD) only allow functions at the start of the line.
 

tiscando

Senior Member
Why isn't there an 'input' etc command available for the 28x and the x1 parts? And should there be variables like dirsa, dirsb, dirsc, dirsd or whatever for the x2 parts (if all it's ports are bidirectional as suggested)?
 

senyabeb

New Member
hi
Umm do you know of any other useful peek or pokes

going through Auckland thursday .up to the top of north island ,is it still wet ?

eric [tasmania]
 
Top