DAT block help
stilgar
Posts: 47
Hello,
I am looking for help on how to use a DAT block. I am wanting to make a data array so I can control 12 pins.
the data i would like to look like this.
111111111111 110010001000
the program would read the 12 bit word and directly control pins connected to that bit
another example would be
pin 12 13 14 15 16 17 18 19 20 21 22 23
1 1 0 0 0 1 1 1 1 1 0 0
1= high 0=low
thanks
I am looking for help on how to use a DAT block. I am wanting to make a data array so I can control 12 pins.
the data i would like to look like this.
111111111111 110010001000
the program would read the 12 bit word and directly control pins connected to that bit
another example would be
pin 12 13 14 15 16 17 18 19 20 21 22 23
1 1 0 0 0 1 1 1 1 1 0 0
1= high 0=low
thanks
Comments
Kwinn, I am using the DIP package. if ports are the same as pins on this package, then yes, ports 12-23.
I am wanting to use spin for the programing. May I ask if you write it, please use lots of comments, so I can understand and learn from it. basically what I want to do is, control a matrix of LEDs. the matrix is 8 LEDs tall and 4 LEDS wide.
thanks,
stilgar
With Spin it is very easy to write a number of contiguous pins with 1 command:
outa[23..12] := value
this writes the lower 12 bits of value to pins 12..23
Here is a little example which combine these: (untested)
Andy
Thanks Andy, It works. only question, how do I calculate the delay to resemble 15 hertz? the manual is a bit low on this area.
thanks again,
stilgar
I assume you read the 4 pages detailing waitcnt (p.218-221). AFAICS there is all the info you need. Which bit do you think is inadequate?
To answer your question: waitcnt(clkfreq/15 + cnt).
Thanks, I am going to have to read it better, I got myself confused because I am using a outside crystal of 5 MHz. I think I have it now, until the next question.
Thanks again everyone,
stilgar