That looks better. I think you may not be getting the best out of the logic analyser - I looked up the specification and it can sample at 25MHz.
Keith
while(!SPI2STATbits.SPIRBF);
I do love to hear *real world* experience, always a pleasure mate, when it's been done for real and working I know it's tested! I will have a quick re-visit on the SPI-MRF24 rf modules now this has sparked some ideas!However, the transmitted data ends up in the receive buffer so when the receive buffer is full the data has been transmitted. That is how I remember it anyway - it is a while since i looked at that code.
unsigned char WriteSPI1(unsigned char Data)
{
// Wait for a data byte reception
while(SPISTATbits.SPITBF);
SPIBUF = Data;
while(!SPISTATbits.SPIRBF);
Data = SPIBUF;
return 0;
}
void _ISR _NOPSV _SPI1Interrupt(void)
{
if (SPI1STATbits.SPIROV) overflow++;
SPIdat[SPIcount] = SPI1BUF; // always read the data
// other code here
_SPI1IF = 0; // clear SPI interrupt
}
void _ISR _NOPSV _CNInterrupt(void)
{
if ((PORTB & 0x0004) == 0) {
SPI1STATbits.SPIEN = 1; // enable SPI
IEC0bits.SPI1IE = 1; //Enable The Interrupt
} else {
SPI1STATbits.SPIEN = 0; // disable SPI
IEC0bits.SPI1IE = 0; //disable The Interrupt
_SPI1IF = 0;
}
_CNIF = 0; // clear CN interrupt
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?