Where would be a good place to start if I want to learn how to write drivers for various hardware devices and what piece of hardware would be an easy item to start with?
I have been writing a driver for the 74HC595, 74HC4094, and 74HC4021 shift registers.
The 595 and 4094 are serial in to 8 bit parallel out, and the 4021 is 8 bit parallel in to serial out.
I'm adding a pair of instructions to Mike Greens FemtoBasic. These code snippets are written in spin:
204: ' SROUT [<expr>] = <expr>
' SROUT [<Pin#>] = <Value>
a := getAddress(dot)
outa[a..a+3] := %0000
dira[a..a+3] := %1110
b := specialExpr
repeat 32
outa[a+2] := b & 1 ' Send a Bit To The Registers
b <-= 1 ' Rotate Left Bits In The Variable
outa[a]~~ ' Shift Left Bits In The Registers
outa[a]~
outa[a+1]~~ ' Strobe The Output Registers
outa[a+1]~
205: ' SRIN [ <expr> ]
t := getAddress(dot)
outa[t..t+3] := %0000
dira[t..t+3] := %1110
i := 0
outa[t+1]~~ ' Strobe The Registers
outa[t+1]~
repeat 32
i += ina[t+3] ' Put a Bit In The Variable
i <-= 1 ' Rotate Left Bits In The Variable
outa[t]~~ ' Shift Left Bits In The Registers
outa[t]~
i += ina[t+3] ' Put Last Bit In The Variable
return i
This simple example expects the there are 4 chips strung in series for a total of 32 bits;
Any combination of output or input devices can be used.
This consumes 4 Prop pins which must be in sequence.
1 = Shift Clock
1+1 = Register Clock
1+2 = Serial Bits Out
1+3 = Serial Bits In
Ok these examples are specific to FemtoBasic but the concept is sound.
Enhancements:
Allow from 1 to 4 or more chips on a set of 4 Prop pins.
I am looking for a code snippet that will be the equivalent of a "ROL", Rotate Left, spin instruction that can rotate 2 to 31 bits instead of the standard 32 bits.
It really is a simple chip to start with. Only needs 3 signals to start with (plus power and ground of course), SER, SCK, and RCK. Download the data sheet and buy a '595 locally along with 8 hi efficiency leds and 8 180 to 220 ohm resistors. Connect the leds and resistors to the output pins of the '595, its SER, SCK, AND RCK pins to 2 free pins on the micro, ground the /G pin, put a pullup on the SRCLR pin and you are off to the races. I can post a block diagram if you want.
Comments
If it's for the propeller I would suggest starting with some simple hardware like the '595 chip.
I have been writing a driver for the 74HC595, 74HC4094, and 74HC4021 shift registers.
The 595 and 4094 are serial in to 8 bit parallel out, and the 4021 is 8 bit parallel in to serial out.
I'm adding a pair of instructions to Mike Greens FemtoBasic. These code snippets are written in spin: This simple example expects the there are 4 chips strung in series for a total of 32 bits;
Any combination of output or input devices can be used.
This consumes 4 Prop pins which must be in sequence.
1 = Shift Clock
1+1 = Register Clock
1+2 = Serial Bits Out
1+3 = Serial Bits In
Ok these examples are specific to FemtoBasic but the concept is sound.
Enhancements:
Allow from 1 to 4 or more chips on a set of 4 Prop pins.
I am looking for a code snippet that will be the equivalent of a "ROL", Rotate Left, spin instruction that can rotate 2 to 31 bits instead of the standard 32 bits.
Duane J
It really is a simple chip to start with. Only needs 3 signals to start with (plus power and ground of course), SER, SCK, and RCK. Download the data sheet and buy a '595 locally along with 8 hi efficiency leds and 8 180 to 220 ohm resistors. Connect the leds and resistors to the output pins of the '595, its SER, SCK, AND RCK pins to 2 free pins on the micro, ground the /G pin, put a pullup on the SRCLR pin and you are off to the races. I can post a block diagram if you want.