Other Parts Discussed in Thread: TMS320F28379D,
Hi team,
Here's an issue from the customer may need your help:
The DAC1282 output DC voltage is controlled using the TMS320F28379D with SPI communication, SPICLK and SPISIMO are normal according to the oscilloscope as the following figure, with a period of 12.5us.
But SPISOMI is always low and the debug interface is unable to read the value of SPISOMI. Please see the below program:
/*
* DAC read debug
*
*/
#include "F28x_Project.h"
typedef unsigned char Uint8;
//Notice
void gpio_init();//Configure all GPIO ports to the PCB board (including 3-wire SPI)
void spia_init();
void dac_init();
void spia_xmit(Uint8 a);
Uint8 rdata;
void main()
{
//Initialization
InitSysCtrl();//System control
InitGpio();//GPIO
DINT;//Turn off the interrupt
InitPieCtrl();//PIE control registers
IER = 0x0000;//The interrupt flag bit is cleared
IFR = 0x0000;//The interrupt flag bit is cleared
InitPieVectTable();//Interrupt vector table
gpio_init();//Configure all GPIO ports to the PCB board (including 3-wire SPI)
spia_init();
dac_init();
spia_xmit(0x20);//Read the GANMOD register address
DELAY_US(100);
spia_xmit(0x00);//Read a register
DELAY_US(100);
while(SpiaRegs.SPISTS.bit.INT_FLAG != 1){}
rdata = SpiaRegs.SPIRXBUF;
}
void gpio_init()
{
/* GPIO connection port I/O The initial value
* 111 GPIO_CS_DA O 0
* 60 SPICLKA_DA SPIA CLK
* 59 SPISOMIA_DA SPIA SOMI
* 58 SPISIMOA_DA SPIA SIMO
* 22 GPIO_SW/TD_DA O 0
*/
EALLOW;
//CS、SW/TD、RESET、DRDY
GpioCtrlRegs.GPDPUD.bit.GPIO111 = 0;
GpioCtrlRegs.GPDMUX1.bit.GPIO111 = 0;
GpioCtrlRegs.GPDDIR.bit.GPIO111 = 1;
GpioDataRegs.GPDCLEAR.bit.GPIO111 = 1;//GPIO_CS_DA
GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0;
GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO22 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO22 = 1;//GPIO_SW/TD_DA
//SPI
//DA(Enable, Asynchronous, SPI)
GpioCtrlRegs.GPBPUD.bit.GPIO60 = 0;
GpioCtrlRegs.GPBQSEL2.bit.GPIO60 = 3;
GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 3;
GpioCtrlRegs.GPBGMUX2.bit.GPIO60 = 3;//SPICLKA_DA
GpioCtrlRegs.GPBPUD.bit.GPIO59 = 0;
GpioCtrlRegs.GPBQSEL2.bit.GPIO59 = 3;
GpioCtrlRegs.GPBMUX2.bit.GPIO59 = 3;
GpioCtrlRegs.GPBGMUX2.bit.GPIO59 = 3;//SPISOMIA_DA
GpioCtrlRegs.GPBPUD.bit.GPIO58 = 0;
GpioCtrlRegs.GPBQSEL2.bit.GPIO58 = 3;
GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 3;
GpioCtrlRegs.GPBGMUX2.bit.GPIO58 = 3;//SPISIMOA_DA
EDIS;
}
void spia_init()
{
//DAC1282 clock polarity (CPOL) is 0 and the clock phase (CPHA) is 0
//configure control register(8-bit reserved,0000 0000 0000 0111 = 0x0007)
SpiaRegs.SPICCR.bit.SPISWRESET = 0;//SPI reset
SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;//clock polarity is 0(SCK idle is low)
SpiaRegs.SPICCR.bit.HS_MODE = 0;//Turns off high-speed mode
SpiaRegs.SPICCR.bit.SPILBK = 0;//Turn off loopback mode
SpiaRegs.SPICCR.bit.SPICHAR = (8-1);//Word length 8 bits
//Run control registers (11-bit reserved,0000 0000 0000 0110 = 0x0016)
SpiaRegs.SPICTL.bit.OVERRUNINTENA = 1;//The receive overflow interrupt is disabled
SpiaRegs.SPICTL.bit.CLK_PHASE = 0;//The clock phase is 0 (sampled on the first transition edge)
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;//MCU host
SpiaRegs.SPICTL.bit.TALK = 1;//Master transmit is enabled
SpiaRegs.SPICTL.bit.SPIINTENA = 0;//SPI interrupts are disabled
//SpiaRegs.SPISTS.all = 0;
//Baud rate register (9-bit reserved,0000 0000 0000 007C)
/*
* LSPCLKfreq=CPUfreq/n //(n=1,2,4,6,8,10,12,14)
* SPI Baud Rate=LSPCLKfreq/(SPIBRR+1)
* Without adding an external auxiliary clock
* The F28379D has a CPU frequency of 10 MHz, which corresponds to a minimum low-speed peripheral clock of 715 KHz and a minimum baud rate of 5586 SPS
* This minimum baud rate is greater than the maximum baud rate of 4000 SPS when FIR filter mode is selected
* Therefore, the sinc filter mode is selected with the baud rate set to 8000 SPS, divide by 10, SPIBRR = 124 = 0x007C
*/
EALLOW;
ClkCfgRegs.LOSPCP.all = 0x0005;//101(10分频)
EDIS;
SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = 0x007C;
//Priority control register
SpiaRegs.SPIPRI.bit.FREE = 1;//Free to run during emulation, pause on breakpoint does not stop the SPI
//Stop SPI software reset to be ready for receive or transmit
SpiaRegs.SPICCR.bit.SPISWRESET = 1;
}
//2、External component initial configuration(DAC、ADC)
void dac_init()
{
spia_xmit(0x40);//Write the GANMOD register address
DELAY_US(100);
spia_xmit(0x00);//write a register
DELAY_US(100);
spia_xmit(0x0D);//write 0000 1101,GAIN=8,DC mode
DELAY_US(100);
//The SINEG register is not configured
spia_xmit(0x42);//Write the SWM register address
DELAY_US(100);
spia_xmit(0x00);//write a register
DELAY_US(100);
spia_xmit(0x10);//write 0001 0000,switches are fully open for differential
DELAY_US(100);
//N registers are not configured
spia_xmit(0x44);//Write the DCG register address
DELAY_US(100);
spia_xmit(0x02);//write three registers
DELAY_US(100);
spia_xmit(0xE9);//DCG0
DELAY_US(100);
spia_xmit(0x26);//DCG1
DELAY_US(100);
spia_xmit(0x31);//DCG2
DELAY_US(100);
//PULSE register is not configured
}
void spia_xmit(Uint8 a)
{
SpiaRegs.SPITXBUF = (Uint16)(a<<8);//Transfers 8-bit data to the serial transmit buffer
}
Could you help check this case? Thanks.
Best Regards,
Cherry