Sai Rahul Sitaram
/
mbed_shiftreg
This is a GR peach project demonstrating shift registers 595 and 165
Revision 0:b9fbca7b029d, committed 2016-12-03
- Comitter:
- RahulSitaram
- Date:
- Sat Dec 03 07:17:34 2016 +0000
- Commit message:
- Shift registers with Grpeach
Changed in this revision
diff -r 000000000000 -r b9fbca7b029d Arduino.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Arduino.lib Sat Dec 03 07:17:34 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/RahulSitaram/code/Arduino/#d0b32a4209f0
diff -r 000000000000 -r b9fbca7b029d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 03 07:17:34 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb \ No newline at end of file
diff -r 000000000000 -r b9fbca7b029d shitreg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shitreg.cpp Sat Dec 03 07:17:34 2016 +0000 @@ -0,0 +1,69 @@ +#include "mbed.h" +//#include <bitset> +#include "arduino.h" + +//using namespace mbed::mbed; + +//DigitalOut lat(P8_11); +//DigitalOut dat(P8_13); +//DigitalOut clk(P4_4); +Serial pc(USBTX, USBRX); // tx, rx +DigitalOut pins[1][3] = {{P8_11,P8_13,P4_4}}; +DigitalIn ser(P2_14); +DigitalOut clk_inh(P4_5); +DigitalOut clk_2(P4_7); +DigitalOut SH_LD(P4_6); + +int delay_time; +int i; +uint8_t init; +uint8_t data_read; +void shift(uint8_t data, int delay_time,int row_no){ + DigitalOut lat = pins[row_no][0]; + DigitalOut dat = pins[row_no][1]; + DigitalOut clk = pins[row_no][2]; + clk = 0; + dat = 0; + lat = 0; + SH_LD = 1; + clk_inh = 1; + clk_2 = 1; + data_read = 0x00; + init = 0x80; + + for(i=0;i<8;i++){ + dat = data & (init>>i); + clk = 1; + clk = 0; + } + lat = 1; + lat = 0; + +} + +uint8_t shift_par(int clk_time, int load_time){ + SH_LD = 0; + wait_us(load_time); + SH_LD = 1; + wait_us(load_time); + data_read = (data_read<<1)|ser; + clk_inh = 0; + + for(i=0;i<8;i++) + { + data_read = (data_read<<1)|ser; + clk_2 = 0; + clk_2 = 1; + + } + + return data_read; + + } + +int main() { + + shift(0x4F, 0, 0); + wait_ms(500); + pc.printf("%c", shift_par(0,0)); +} \ No newline at end of file