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’?
PORT command in Basic
-
- Posts: 9
- Joined: Wed Jan 21, 2015 9:56 am
- Location: Seguin, TX
- Contact:
Re: PORT command in Basic
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!)
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!)
-
- Posts: 9
- Joined: Wed Jan 21, 2015 9:56 am
- Location: Seguin, TX
- Contact:
Re: PORT command in Basic
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.