View Single Post
Old 03-12-2010, 06:39 PM   #1
Double_Dion
Crash and Bang Winger
 
Join Date: Mar 2007
Exp:
Default dsPic30F3014 SPI interfacing

I am using MPLAB compiler and I am using a dsPic mcu. I am trying to interface with the spi to send data to a peripheral (audio attenuator) using C coding. I think I have the initialization correct, but I am stumped.



//************************************************** **********//

#include <stdio.h>
_FOSC(CSW_FSCM_OFF & XT_PLL8); // (clock switching and fail safe monitor are disabled &
// crystal connected to OSC1 is the clock source (8x PLL applied, primary oscillator)
_FWDT(WDT_OFF); // Watchdog timer disabled
_FBORPOR(PBOR_OFF & BORV_27 & PWRT_16 & MCLR_EN); // Brown-out reset disabled &_____&____& MCLR reset enabled


#define FCY 8000000 // Instruction cycle rate (Osc(4Mhz) x PLL(8) / 4) = 8 MIPS
#define T1Period 800 // T1Period = FCY*100 us = 800

void setup_spi();

int main()
{

setup_spi();

return 0;
}


//***********************
void setup_spi()
{

SPI1CON = 0x063E; // 0000 | 0110 | 0011 | 1110
SPI1STAT = 0x8000; // enable SPI port

printf("To C, or not to C: that is the question.\n");

return;
}[/CODE]

Last edited by Double_Dion; 09-07-2010 at 10:13 PM.
Double_Dion is offline   Reply With Quote