Hi All,
I am facing one more issue in gpio interrupt.
i am sending 0x06,0xBC,0xAB data from KEAZN64 to S9S12GA240
(before sending data i am making one gpio(PP0) high to low which is connected between both )
I am receiving data in gpio interrupt handler.
1. but if i received data in main handler there is no loss of data.
1. but if i received data in interrupt handler there is loss of data.
Here will be interrupt and spi init code.
SPI1CR2 = 0x10; //8bit //0x10; /* 8-Bit transfer width; SS pin is used by the SPI */
SPI1BR = 0x28;//0x28; //0x77;//0x77; //0x41; //0x77; /* SPI clock = Bus Clock divided by 2048 = 15.625kHz */
SPI1CR1 = 0x40; //pol,pha =0; slave mode, MSB first //0x56; /* SPI enabled; Master mode; Active high clocks; Slave Select output enabled*/
/* Enable Interrupt on Port P, P7 */
//PERP = 0x03;
//PIEP_PIEP1 = 1;
DDRP_DDRP0=0; // make as input
PERP_PERP0=1; // pull up enable
PPSP_PPSP0=0;
PIEP_PIEP0=1;
EnableInterrupts;
Once i used the fallowing code in main loop , there is no loss of data.
LF;
while(rx_data[rx_cnt]!=0xAB)
{
while(SPI1SR_SPIF == 0);
rx_data[rx_cnt] = SPI1DRL;
DisplayByte(rx_data[rx_cnt]);
LF;
//rx_cnt++;
//while(SPI1SR_SPTEF==0);
//SPI1DRL = 0xBA;
}
rx_data[rx_cnt]=0x00;
DisplayString("End intertttput handler ");
LF;
i am getting all 3 data (0x06,0xBC,0xAB)
but if i used same thing in interrupt handler, i am getting only 0x06,0xAB.
means 0xBC is missing.
Here will be my interrupt handler.
#pragma TRAP_PROC
void interrupt VectorNumber_Vportp PORTPP_ISR(void)
{
unsigned char rx_data[12]={0},rx_cnt=0;
interrupt_Flag = 1;
DisplayString("IN intertttput handler ");
LF;
while(rx_data[rx_cnt]!=0xAB)
{
while(SPI1SR_SPIF == 0);
rx_data[rx_cnt] = SPI1DRL;
DisplayByte(rx_data[rx_cnt]);
LF;
//rx_cnt++;
//while(SPI1SR_SPTEF==0);
//SPI1DRL = 0xBA;
}
rx_data[rx_cnt]=0x00;
DisplayString("End intertttput handler ");
LF;
PIFP=0x01;
}
#pragma CODE_SEG DEFAULT
Could you please let me know what may the the problem?.