I am using MPLAB IDE C30 compiler and I am using a dsPic30f3014 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 on how to actually send data. I was able to compile and got the correct 'printf' output.
Can someone please tell me how to actually send data via the SPI?
Can someone please tell me how to actually send data via the SPI?
Code:
// EE 400/401
// Group #27: Audio normalizer
// SPI interfacing
//************************************************************//
#include <p30F3014.h>
#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;
}