PORT command in Basic

PORT command in Basic

Postby speedracer » Sat May 30, 2020 3:48 pm

I want to ask a question about the Basic command, PORT. I would like to read a 12-bit input on my EzSBC1 and print the result as a number. If I understand this command, I can set 12 pins to inputs (P0.0 to P0.11, say), execute x = PORT(0), and then AND the result with some appropriate number to get my result, yes? Only my attempts to do this result in odd results. Not the least of which is the number is a huge floating-point number.

The text in the Basic manual is, well, hard to comprehend. Not least is the difference in nomenclature. For example, what pin on the board is represented by P1.0 or P1.31? These don’t seem to correspond to board pins.

Can you enlighten me? How would I read 12 input pins as a ‘port’?
speedracer
 
Posts: 9
Joined: Wed Jan 21, 2015 12:56 pm
Location: Seguin, TX

Re: PORT command in Basic

Postby Janke » Sat May 30, 2020 4:15 pm

Well, the PORT command gives you a 32-bit value, which should NOT be considered as a number - rather, each BIT in the value represents the state of one port.

So you need some binary operations ( &, |, and ^ ) to get the state of the port. See page 23-24 in the manual.

If you use AND and OR commands, you'te handling the value as a number - hence the floating point result.

The actual port numbers for the pins can be found in the schematic. Only pins 10 to 23 have the same number as in port P0.

I assume you have downloaded all documents? If not, they are available from the EzSBC website.

Best regards,

Janke (a user in Finland!)
Janke
 
Posts: 29
Joined: Mon Feb 20, 2017 2:48 pm

Re: PORT command in Basic

Postby speedracer » Mon Jun 01, 2020 6:39 pm

Thanks for the tip to look at the schematic! I revised my test board and can now read input bits. The difficulty is finding which 12 bits will work best as there are some gaps and some dedicated port pins that I will have to work around. But I think I can accomplish what I need to.
speedracer
 
Posts: 9
Joined: Wed Jan 21, 2015 12:56 pm
Location: Seguin, TX


Return to EzSBC1

Who is online

Users browsing this forum: No registered users and 1 guest

cron