hey guys i got some wierd !#$@ here i'm tryin to read PORTC using the peek command:
first i set PORTC to in and pullup
dir PORTC.0 in
set PORTC.0 on
dir PORTC.1 in
set PORTC.1 on
dir PORTC.2 in
set PORTC.2 on
dir PORTC.3 in
set PORTC.3 on
dir PORTC.4 in
set PORTC.4 on
dir PORTC.5 in
set PORTC.5 on
dir PORTC.6 in
set PORTC.6 on
dir PORTC.7 in
set PORTC.7 on
ok i'll check that......
well i don't follow what it's saying about the specific syntax of uservar = pinx
i have to do a for loop. so will it work if i do this?
forx=1to10array(x)=pinxnext
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
no there's actually 69 pins that i have to address via a FOR loop.
every pin on the mega board. ports A thru L
so i had an array of port memory addresses and a for loop like
" for xx = 1 to 69
localvar = peek(addresses(xx))"
but that didn't work because peek(address) always returns 255 regardless of the state of the pins.
Last edit: louie 2018-05-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
dim addresses(3)
addresses = 34, 37, 40 ' ports a b and c
dim pins(3)
mask = 0b01101001
for xx = 1 to 3
inbyte = peek(addresses(xx))
pins(xx) = inbyte & mask
next
problem is that peek doesn't work. so the code that Anobium posted above will work, but only for a single port.
Last edit: louie 2018-05-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yeah..... that's damn clever. and it's probably as elegant as it's gonna get. cause it looks like there's just no way to numerically reference those ports, at least not with GCB.
THANX, stan. i'm gonna use your routine and get back to the job.
mike :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hey guys i got some wierd !#$@ here i'm tryin to read PORTC using the peek command:
first i set PORTC to in and pullup
then i read the port by using peek:
then i take a wire and ground one of the PORTC pins, but nothing happens. the light won't come on.
then i change to this:
now it works. ground out pinC3 and the lite comes on. but i gotta figure out why the peek does not work. anybody know what's up?
Last edit: louie 2018-05-01
Dont peek - in all my years.. never used peek. Simply use PINC. See the Help Inputs/Outputs.
ok i'll check that......
well i don't follow what it's saying about the specific syntax of uservar = pinx
i have to do a for loop. so will it work if i do this?
No. Is there 10 ports on the microcontroller you are using?
Something like this... this is portable code - no peek. It may be faster to simply assigned the pin to the array element.
no there's actually 69 pins that i have to address via a FOR loop.
every pin on the mega board. ports A thru L
so i had an array of port memory addresses and a for loop like
" for xx = 1 to 69
localvar = peek(addresses(xx))"
but that didn't work because peek(address) always returns 255 regardless of the state of the pins.
Last edit: louie 2018-05-01
Do you monitor each port bit then stop? else localvar will always be port 69.
Please explain your plan in more detail.
well here's a simplified example:
problem is that peek doesn't work. so the code that Anobium posted above will work, but only for a single port.
Last edit: louie 2018-05-01
it's late. not elegant.
yeah..... that's damn clever. and it's probably as elegant as it's gonna get. cause it looks like there's just no way to numerically reference those ports, at least not with GCB.
THANX, stan. i'm gonna use your routine and get back to the job.
mike :-)