Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem when trying to clock continuous data stream out using the SPI with PIC24F

Status
Not open for further replies.

RichardH

Newbie level 5
Joined
Mar 2, 2006
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
England
Activity points
1,359
Hi

I am trying to clock a continuous data stream out using the SPI port (I never read anything back), ideally, I would like a 16 bit word with an interrupt to reload the SPI1BUF every time it is empty.

I set up the SPI

TRISF = 0x0140;
CLKDIV = 0x0040;
SPI1CON1 = 0x013B;
SPI1CON2 = 0x0000;

SPI1STATbits.SISEL0 = 1; // set SISEL to 101 to enable interrupt driven output
SPI1STATbits.SISEL1 = 0;
SPI1STATbits.SISEL2 = 1;
SPI1CON1bits.MODE16 = 1; // put into 16 bit mode
SPI1STATbits.SPIEN = 1; // Enable the SPI

IFS0bits.SPI1IF = 1; // clear interrupt flag
IEC0bits.SPI1IE = 1; // enable interrupt


my interrupt routine

void __attribute__((__interrupt__, no_auto_psv)) _SPI1Interrupt(void)
{
SPI1BUF = data[count++];
IFS0bits.SPI1IF = 0;
}

the interrupt gets called 2 or 3 times, then never again..........but I am clearing the flag, so I am not sure why it stops.

I tried adding

IFS0bits.SPF1IF = 0;

to the interrupt service routine, just in case I was getting an error (as I am not receiving anything), but this doesn't help.

Any ideas what I have missed?

Thanks

Richard

Added after 5 hours 36 minutes:

Having been trying different things, I have found that If I set

SPI1STATbits.SPIROV =0;

in the interrupt, then it seems to continue onwards with the interrupt, however, I am not sure this is correct as I dont seem to see any clock and data pulses coming out.

Any ideas?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top