varunme
Advanced Member level 3
- Joined
- Aug 10, 2011
- Messages
- 741
- Helped
- 17
- Reputation
- 36
- Reaction score
- 17
- Trophy points
- 1,318
- Activity points
- 5,765
Last edited:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I shorted the shift clock and latch clock, so it uses only two pins
it works in proteus, but in real hardware, not
i added 1uf in QH' to gnd, same result
It "works" in a way that all output pins get same data...I shorted the shift clock and latch clock, so it uses only two pins it works in proteus.
sbit SR_Latch at RC1_bit;
//sbit SR_Enable at RC2_bit;
sbit SR_Latch_Direction at TRISC1_bit;
//sbit SR_Enable_Direction at TRISC2_bit;
void main() {
trisc=0;
trisD=0;
portc=0;
portd=0;
SPI1_Init();
while(1) {
long a=0b00000001000001000000000000000111;
//SPI1_Write(0b00000001);
//SPI1_Write(a>>24);
SPI1_Write(a>>16);
SPI1_Write(a>>8);
SPI1_Write(a);
SR_Latch = 1;
PORTC.F0=1;
PORTD.F2=0;
delay_ms(1000);
SR_Latch = 0;
PORTC.F0=0;
PORTD.F2=0;
a=0b11110000000000000000000000000000;
//SPI1_Write(0b00001000);
//a=~a;
//SPI1_Write(a>>24);
SPI1_Write(a>>16);
SPI1_Write(a>>8);
SPI1_Write(a);
SR_Latch = 1;
PORTC.F0=1;
PORTD.F2=1;
delay_ms(1000);
SR_Latch = 0;
PORTC.F0=0;
PORTC.F2=0;
}
}
That capacitor has to be connected between QH' and which pin?
if ((_BV(i) & __led_state) == _BV(i))
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 #define Lo(param) ((char *)¶m)[0] #define Hi(param) ((char *)¶m)[1] #define Higher(param) ((char *)¶m)[2] #define Highest(param) ((char *)¶m)[3] sbit SH_CP at RC3_bit; sbit SH_CP_Direction at TRISC3_bit; sbit ST_CP at RC4_bit; sbit ST_CP_Direction at TRISC4_bit; sbit DS at RC5_bit; sbit DS_Direction at TRISC5_bit; unsigned long s_data = 0xAA55; void SPI_Send(unsigned char s) { unsigned char mask = 0x80; char i = 0; for(i = 0; i < 8; i++, mask >> 1) { if(s & mask) DS = 1; else DS = 0; SH_CP = 1; Delay_ms(2); SH_CP = 0; } ST_CP = 1; Delay_ms(2); ST_CP = 0; } void main() { TRISA = 0xC0; TRISB = 0x00; TRISC = 0x00; TRISD = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; SH_CP_Direction = 0; SH_CP = 0; ST_CP_Direction = 0; ST_CP = 0; DS_Direction = 0; DS = 0; while(1) { SPI_Send(Highest(s_data)); Delay_ms(2000); SPI_Send(Higher(s_data)); Delay_ms(2000); SPI_Send(Hi(s_data)); Delay_ms(2000); SPI_Send(Lo(s_data)); Delay_ms(2000); } }
switch(uart_rd){
case1: x=0b000011100011001;
case2: x=0b000011100011001;
casea: x=0b000011100011001;
caseb: x=0b000011100011001;
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 #define Lo(param) ((char *)¶m)[0] #define Hi(param) ((char *)¶m)[1] #define Higher(param) ((char *)¶m)[2] #define Highest(param) ((char *)¶m)[3] sbit SH_CP at RC3_bit; sbit SH_CP_Direction at TRISC3_bit; sbit ST_CP at RC4_bit; sbit ST_CP_Direction at TRISC4_bit; sbit DS at RC5_bit; sbit DS_Direction at TRISC5_bit; char uart_rd = 0, i = 0, j = 0; char sequence[12] = {0b11000011, 0b11011011, 0b11100011, 0b11000011, 0b11111011, 0b11100011, 0b11000011, 0b11011011, 0b11100011, 0b11010011, 0b11011011, 0b11110011}; void interrupt() { if(RCIF_bit) { if(OERR_bit) { CREN_bit = 0; CREN_bit = 1; OERR_bit = 0; } uart_rd = UART1_Read(); RCIF_bit = 0; } } void SPI_Send(char s) { char mask = 0x80; char i = 0; for(i = 0; i < 8; i++, mask >> 1) { if(s & mask) DS = 1; else DS = 0; SH_CP = 1; Delay_ms(2); SH_CP = 0; } ST_CP = 1; Delay_ms(2); ST_CP = 0; } void main() { TRISA = 0xC0; TRISB = 0x00; TRISC = 0x00; TRISD = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; SH_CP_Direction = 0; SH_CP = 0; ST_CP_Direction = 0; ST_CP = 0; DS_Direction = 0; DS = 0; UART1_Init(9615); Delay_ms(200); UART1_Write_Text("Send a byte\r\n"); UART1_Write_Text("--------------\r\n\r\n"); RCIE_bit = 1; PEIE_bit = 1;; GIE_bit = 1; while(1) { switch(uart_rd) { case '0': i = 0; break; case '1': i = 3; break; case '2': i = 6; break; case '3': i = 9; break; }; if(uart_rd) { for(j = i; j = (i + 3); j++) { SPI_Send(sequence[j]); Delay_ms(2000); } } } }