• AVR Freaks

Hot!dsPIC33CK256MP506 - SPI - During debug, Target halts if SPI1RXIE interrupt is enabled

Author
JJAYAR
Starting Member
  • Total Posts : 34
  • Reward points : 0
  • Joined: 2011/11/30 20:40:39
  • Location: 0
  • Status: offline
2020/04/08 22:08:58 (permalink)
0

dsPIC33CK256MP506 - SPI - During debug, Target halts if SPI1RXIE interrupt is enabled

Set up chip for SPI  Master operation
CHip seems to transfer data correctly to slave chip(I can capture on scope & see clock, dataout & dataIn)
However if I try to transfer data with interrupt receive buffer full interrupt enabled, the debugger halts the target immedeately after loading SPI buffer
(SPI is set up for 16bit xfer)
 
SPIXchangeData(int spiDataToSend)
{
IPC2bits.SPI1rXIP = 4;
//BAUD RATE SET TO ABOUT 0.7MHz
      IFS0bits.SPI1RXIF = 0; //clear interrupt flag
    SPI1STATLbits.SPIROV = 0;
    SPI1IMSKLbits.SPIRBFEN = 1;//receive buffer full interrupt
    IEC0bits.SPI1RXIE = 1;//enable interrupt---this will cause target to halt
    SPI1STATLbits.SPITBE = 1;//
    SPI1BUFL = 0x0F; //write command to buffer
}
 
void __attribute__((interrupt, no_auto_psv)) _SPI1Interrupt(void) {
spiDataReceived = SPI1BUFL;
IFS0bits.SPI1RXIF = 0;//clear receive interrupt flag
}
I was wondering if anyone has experienced a similar situation
Any comments welcome
 
Thank you in advance for your help
 
Jay 
 
#1

3 Replies Related Threads

    JPortici
    Super Member
    • Total Posts : 1017
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: dsPIC33CK256MP506 - SPI - During debug, Target halts if SPI1RXIE interrupt is enabled 2020/04/09 01:06:42 (permalink)
    0
    The compiler is supposed to be throwing a warning, as _SPI1Interrupt is not a predefined interrupt name for dsPIC33CK parts.
     
    Go read the datasheet, interrupt controller. You'll see that there are two vectors for each SPI module, one for SPInRX and one for SPInTX
     
    So basically you have NOT declared the interrupt routine :)
    #2
    JJAYAR
    Starting Member
    • Total Posts : 34
    • Reward points : 0
    • Joined: 2011/11/30 20:40:39
    • Location: 0
    • Status: offline
    Re: dsPIC33CK256MP506 - SPI - During debug, Target halts if SPI1RXIE interrupt is enabled 2020/04/09 19:48:33 (permalink)
    0
    Thanx for your help Jack
    I have changed the routine name no more lock ups!
    However, the program does not seem to go to the interrupt routine at all
    I was wondering if I have to set any other bits
    SPIXchangeData(int spiDataToSend)
    {
    IPC2bits.SPI1rXIP = 4;
    //BAUD RATE SET TO ABOUT 0.7MHz
          IFS0bits.SPI1RXIF = 0; //clear interrupt flag
        SPI1STATLbits.SPIROV = 0;
        SPI1IMSKLbits.SPIRBFEN = 1;//receive buffer full interrupt
        IEC0bits.SPI1RXIE = 1;//enable interrupt---this will cause target to halt
        SPI1STATLbits.SPITBE = 1;//
        SPI1BUFL = 0x0F; //write command to buffer
    }
    ///=========
    void __attribute__((interrupt, no_auto_psv))_SPI1RXInterrupt(void) {
    //all SPI variables
    spiDataReceived = SPI1BUFL;
    IFS0bits.SPI1RXIF = 0;//clear receive interrupt flag
    }
    #3
    JJAYAR
    Starting Member
    • Total Posts : 34
    • Reward points : 0
    • Joined: 2011/11/30 20:40:39
    • Location: 0
    • Status: offline
    Re: dsPIC33CK256MP506 - SPI - During debug, Target halts if SPI1RXIE interrupt is enabled 2020/04/09 22:22:56 (permalink)
    0
    Jack- Thank you once again for your advice
    I think I got a handle on this one - The SPI seems to be doing its job now
    Jay
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5