Hello,
I need to establish one way SPI connection for communication between c6748 lcdk and AD5932.
In my code I use drivers, examples and h-files from C6748_StarterWare_1_20_03_03.
I wanted to varify the frequency of SPI0_CLK on oscilloscope, but there is no signal.
Please could you have a look into my code and write where is the mistake? I can not see where the mistake is.
Thank you.
Petr Duga
#include "hw_psc_C6748.h"
#include "psc.h"
#include "soc_C6748.h"
#include "lcdkC6748.h"
#include "spi.h"
#include "gpio.h"
#include "hw_gpio.h"
/*value needed to write log 1 to SIMO and CLK bits in Pin Control Register 0 (SPIPC0)*/
#define SIMO_CLK (0x00000600)
unsigned int *val;
/*character length value*/
#define CHAR_LENGTH (0x10)
/*
* main.c
*/
int main(void) {
/* Waking up the SPI0 instance. The local PSC number for SPI0 is 4. SPI0 belongs to PSC0 module*/
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_SPI0, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
/* The Local PSC number for GPIO is 3. GPIO belongs to PSC1 module.*/
PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
/*Pin multiplexing SPI0 and GPIO*/
SPI0_CLKPinMuxSetup();
SPI0_SIMOPinMuxSetup();
GPIOBank8Pin10PinMuxSetup();
GPIOBank8Pin12PinMuxSetup();
/*SPI0 set up*/
SPIReset(SOC_SPI_0_REGS);
SPIOutOfReset(SOC_SPI_0_REGS);
/*LCDK board is MASTER*/
SPIModeConfigure(SOC_SPI_0_REGS, SPI_MASTER_MODE);
/*Setting of register SPIPC0 to enable SIMO and CLK signals of SPI*/
*val=SIMO_CLK;
SPIPinControl(SOC_SPI_0_REGS, 0, 0, val);
/*Setting of SPI clock frequency*/
SPIClkConfigure(SOC_SPI_0_REGS, 228000000, 40000000, SPI_DATA_FORMAT0);
/*Setting of clock format*/
SPIConfigClkFormat(SOC_SPI_0_REGS,(SPI_CLK_POL_LOW | SPI_CLK_OUTOFPHASE),SPI_DATA_FORMAT0);
SPIShiftMsbFirst(SOC_SPI_0_REGS, SPI_DATA_FORMAT0);
SPICharLengthSet(SOC_SPI_0_REGS, CHAR_LENGTH, SPI_DATA_FORMAT0);
/*I expected, that after this method will appear CLK signal on SPI0_CLK in J15 - this does not work */
SPIEnable(SOC_SPI_0_REGS);
GPIODirModeSet(SOC_GPIO_0_REGS, 139, GPIO_DIR_OUTPUT);
/*spying on GPIO8[10] in J15 with oscilloscope - this works*/
/*
while(1)
{
GPIOPinWrite(SOC_GPIO_0_REGS, 139, GPIO_PIN_HIGH);
//int delay=1000;
//while(delay)
// delay--;
GPIOPinWrite(SOC_GPIO_0_REGS, 139, GPIO_PIN_LOW);
}
*/
}