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.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top