RAJPUT VIDISHA
Member level 1
Hi,
I'm doing SPI Bit Banging using PIC16F1718 as slave. I could make it work but only for 1 byte i.e by using char rdata, where rdata is the buffer which stores the incoming bits. so, now i want to use int so that i can store more than 1 byte, but it's giving me errors like:
-> Operator '.' is not applicable to these operands 'rdata'
-> Internal error 'undefined aggregate'
->Internal error 'undefined struct'
I'm attaching my complete working code. I have highlighted the lines with Blue color. Please once have a look and tell me how to use int to make it work.
Regards
Vidisha
I'm doing SPI Bit Banging using PIC16F1718 as slave. I could make it work but only for 1 byte i.e by using char rdata, where rdata is the buffer which stores the incoming bits. so, now i want to use int so that i can store more than 1 byte, but it's giving me errors like:
-> Operator '.' is not applicable to these operands 'rdata'
-> Internal error 'undefined aggregate'
->Internal error 'undefined struct'
I'm attaching my complete working code. I have highlighted the lines with Blue color. Please once have a look and tell me how to use int to make it work.
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 sbit CE at RB4_bit; sbit CE_Direction at TRISB4_bit; [COLOR="#0000FF"]unsigned int rdata ;[/COLOR] unsigned char data_read_flag; int count; unsigned char i; void main(){ OSCTUNE = 0x80; OSCCON = 0b01110010; RXPPS = 0x17; RC6PPS = 0X14; ANSELA = 0x00; //PORT A as Digital ANSELB = 0x00; ANSELC = 0x00; TRISA = 0b00010001; TRISB = 0b00110100; TRISC = 0b10000000; IOCBN = 0X10; //Enable IOC on RB4 -VE Edge of CE INTCON = 0x88; UART1_Remappable_Init(9600); do{ if(data_read_flag == 1){ PORTC.B6 = ~PORTC.B6; } }while(1); } void interrupt(){ //case for falling edge of CE //IOCBN4_bit if(IOCBN4_bit && IOCBF4_bit && IOCIF_bit) //If RB4 Lower Edge is detected ,IOCBF4_bit is 1 { IOCBP5_bit = 1; // enabling interrupt on rising edge of RB5 i.e., CLK IOCBP.B4 = 1; // enabling interrupt on rising edge of CE IOCBN4_bit = 0; //Disabling the interrupt on CE -ve Edge IOCBF4_bit = 0; //Disabling RB4 flag bit IOCIF_bit = 0; //Disabling IOC flag bit count = 0; } if(IOCBF5_bit && IOCIF_bit ) //If RB5 Rising Edge Detected { IOCBF5_bit = 0; //Disabling RB5 Flag bit IOCIF_bit = 0; //Disabling IOC flag bit count = count + 1; [COLOR="#0000FF"] rdata.B0 = PORTA.B0; //Reading Data on RA0 pin[/COLOR] if(count<8){ rdata = (rdata << 1) ; //shifting the incoming bits to the left } } if( IOCBP4_bit && IOCBF4_bit && IOCIF_bit) { data_read_flag = 1; IOCBP.B4 = 0; //Disable IOC on Rising Edge of RB4 IOCBP.B5 = 0; //Disable IOC on Rising Edge of RB5 IOCBN.B4 = 1; // enabling interrupt for the next transaction IOCBP4_bit = 0; IOCIF_bit = 0; UART1_Remappable_Write(rdata ); } }
Regards
Vidisha
Last edited by a moderator: