dsPIC33ep128gp506 SPI1 not working

Status
Not open for further replies.

Alias.Moniker

Newbie level 2
Joined
Apr 22, 2017
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
15
Guys,

I am trying to use SPI1 of dsPIC33ep128gp506.

here are the pins interfaced
Code:
AD-CS1    - PIN E.15 \n
AD-CS0    - PIN A.8 \n
AD-MOSI  - PIN A.4 \n
AD-MISO  - PIN A.9 \n
AD-SCK    - PIN C.3 \n

Here is the code for initialisation of SPI engine...
Code:
    SPI1CON1 = 0x0049;
    SPI1CON2 = 0x00;
    SPI1STAT = 0x000C;
    SPI1CON1bits.MSTEN = 1; 
    SPI1STATbits.SPIEN = 1;

Here is the code for writing data over SPI...
Code:
            HAL_SPI_EnableSlave(eSlave);  //ChipSelect Low           
            u8Dummy = SPI1BUF;
            SPI1BUF = u8Reg;
            while (!SPI1STATbits.SPIRBF);
             u8Dummy = SPI1BUF;
            SPI1BUF = u8Data;
            while (!SPI1STATbits.SPIRBF);  
            HAL_SPI_DisableSlave(eSlave);  //ChipSelect High


Now, when I try to run the program, I don't see any activity on SCK and MOSI lines.
Even if it would be a problem of OSC setttings, I would have seen some waveform on SCK lines but SCK is continuously HIGH (IDLE).

Please let me know, where I am getting wrong.
 

Did you verify that the processor is running at all, e.g. can blink a LED?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…