Setup the input and output on 20X2

Hansen

Member
I work on a project where i use PICAXE 20 X 2

I need to specify input & output on easy way

B port all the time use for 8 bit output together

C.4 - C.7 is use for input

C.1 - C.2 Is input from a PC keyboard for feature use

C.0 is output as a clock to tell the system that there is date from PORT B from (0 to 500 time pr. min)

picaxe 20 x 2 all time connected to a PC on serial port

the my Question

1. how do i setup port C

2. how do i read C.4-C.7 in to variable(B22) Easy and fast read 50 a sec
 

Attachments

Chavaquiah

Senior Member
1) Use DirsX = %xxxxxxxx where pins are (left to right) 7,6,5,...,1,0 and x=1 means output, x=0 means input.

dirsB=%11111111 'All portB pins Output
dirsC=%00000001 'Port C pins 7654321=In, Pin 0=Out


2) b22 = PinsC / 16
or
b22 = PinsC >> 4
 

Hansen

Member
Thx for info

Now come the next question

I have some number to be store in basic line

exm: 01h,2Eh,3Fh,74h,79h,,,,,,,88h

up to 100 value

and how do i use them i shut use 1 at the time
 

Chavaquiah

Senior Member
I'm not sure I understood your question fully (English is not my native language).

I think you should be looking at the EEPROM (or DATA) command to store those number to memory and then READ to... well, to read them.

As in:

Code:
DATA 0, ($01, $2E, $3F, $74) 'Start storing data at address zero
DATA ($79, ...etc... , $88) 'Continue storing data at next address

Then, in the program:

Code:
for b0 = 0 to 99
   read b0, b1
   'Do something with b1
next b0
 

Hansen

Member
I'm not sure I understood your question fully (English is not my native language).

I think you should be looking at the EEPROM (or DATA) command to store those number to memory and then READ to... well, to read them.

As in:

Code:
DATA 0, ($01, $2E, $3F, $74) 'Start storing data at address zero
DATA ($79, ...etc... , $88) 'Continue storing data at next address

Then, in the program:

Code:
for b0 = 0 to 99
   read b0, b1
   'Do something with b1
next b0

I don't free pin on the PICAXE to add EEPROM

Then if i want to use for 17 to 32
for b0=17 to 32
read b0,b1
´Do´
next b0



is the max 256 element i can store in that way ??
 
Last edited:

Chavaquiah

Senior Member
This instruction would be to use the internal eeprom space available with the 20X2. No external EEPROM and no extra pin needed. The 20x2 has 256 bytes of EEPROM memory available. That should be enough to store your 100 numbers.

You can read any of those bytes at any time with READ addr, result so you're quite correct: to use 17 to 32 you would use READ 17, xxx ... READ 32, xxx

If you need to store more than 256 bytes, and since you're using an X part (X1 or X2), I think you can also use the command TABLE to set aside another 256 bytes from the program memory. The commands would be TABLE (to store values) and READTABLE to read them.

I think this would give you up to 512 bytes (256 eeprom + 256 table). I'm not entirely sure. Perhaps someone could confirm this?
 
Top