This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049: SPIB pin configuration problem

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE, SYSCONFIG

Dear team:

One of my customers wants to configure SPIB as SPI communication port, but he has a problem with GPIO configured in the form of register, because GPIO configured in the form of library function can communicate normally. Can you check the configuration below for any problems?

//说明 F280049 SPIB 配置说明
// SIMO---GPIO56   SOMI---GPIO25   CLK---GPIO26   SET----GPIO27
//

void InitSoib(void)
{
	EALLOW;

	//初始化引脚
	SpibinitPin();
	
	//使能SPI-B时钟
	CpuSysRegs.PCLKCR8.bit.SPI_B = 1;

	//SPI复位设置
	SpibRegs.***.bit.SPISWRESET = =0;
	DELAY_US(10);

	//设置收发模式
        SpibRegs.***.bit.CLKPOLARITY = 0;
	SpibRegs.***.bit.CLK_PHASE = 1;

	//设置收数据位数
	SpibRegs.***.bit.*** = (8 - 1);

	//溢出中断禁止信号延时半周期使能,主动模式,使能发送,禁止SPI中断
	SpibRegs.***.bit.OVERRUNINTENA = 0;//溢出中断禁止
	SpibRegs.***.bit.MASTER_SLAVE = 1; //主动模式
	SpibRegs.***.bit.TALK  = 1;//使能发送
        SpibRegs.***.bit.SPIINTENA = 0;//禁止SPI中断

	//设置波特率
	
	SpibRegs.SPIBRR.bit.SPI_BIT_RATE = ((100E6 / 4) / 500E3) - 1;

	//SPI自由运行状态
	SpibRegs.SPIPRI.all = 0x10;

	//接受溢出使能。默认值1111
	SpibRegs.SPIFFCT.all = 0x204F;

	//无延时
	SpibRegs.SPIFFCT.all = 0x0;

	//完成复位
	SpibRegs.***.bit.SPISWRESET = 1;


	EDIS;


}

//GPIO配置
void SpibinitPin(void)
{
	//SPISIMO
	GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 1;//设置为SPI模式
	GpioCtrlRegs.GPBDIR.bit.GPIO56  = 1; // 输出
        GpioCtrlRegs.GPBPUD.bit.GPIO56  = 0; // 使能上拉电阻

        //SPISOMI
	GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 1;//设置为SPI模式
	GpioCtrlRegs.GPADIR.bit.GPIO25  = 0; // 输入
	GpioCtrlRegs.GPAQSEL2.bit.GPIO25  = 3; // 异步输入
        GpioCtrlRegs.GPAPUD.bit.GPIO25  = 0; // 使能上拉电阻

        //CLK
	GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 1;//设置为SPI模式
	GpioCtrlRegs.GPADIR.bit.GPIO26  = 1; // 输出
        GpioCtrlRegs.GPAPUD.bit.GPIO26  = 0; // 使能上拉电阻


        //使能
	GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 1;//设置为SPI模式
	GpioCtrlRegs.GPADIR.bit.GPIO27  = 1; // 输出
        GpioCtrlRegs.GPAPUD.bit.GPIO27  = 0; // 使能上拉电阻
	

}

Best regards

  • Green,

    Looks like pinmux configuration in SpibinitPin() is not complete. For example, for GPIO56 you need to select mode 9 (1001b) for SPIB_SIMO mode. Write GPBGMUX2.GPIO56 = 10b and GPBMUX2.GPIO56 = 01b.

    For SPI configuration, you can point the customer to the SPI bit field examples in C2000ware, if they are not already aware these exist.

    C:\ti\c2000\C2000Ware_3_04_00_00\device_support\f28004x\examples\spi

  • Dear Gus:

    Thank you for your reply.

    My customer has updatad the GPxMUX2 configuration, but it doesn't seem to work. Do you have any other advice? 

    //GPIO配置
    void SpibinitPin(void)
    {
    	//SPISIMO
    	GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 9;//SPISIMO
        GpioCtrlRegs.GPBPUD.bit.GPIO56  = 0; // 使能上拉电阻
    
            //SPISOMI
    	GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 6;//SPISOMI
    	GpioCtrlRegs.GPAQSEL2.bit.GPIO25  = 3; // 异步
        GpioCtrlRegs.GPAPUD.bit.GPIO25  = 0; // 使能上拉电阻
    
            //CLK
    	GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 6;//CLK
            GpioCtrlRegs.GPAPUD.bit.GPIO26  = 0; // 使能上拉电阻
    
    
            //使能
    	GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 0;//设置为数字IO
    	GpioCtrlRegs.GPADIR.bit.GPIO27  = 1; // 输出
            GpioCtrlRegs.GPAPUD.bit.GPIO27  = 0; // 使能上拉电阻
            GpioCtrlRegs.GPACLEAR.bit.GPIO27  = 1;//片选 使能
    	
    
    }

    Best regards

  • Hi Green,

    There are 2 MUX registers : MUX and GMUX which you need to configure. These fields are 2 bit long. The upper 2 bits of the mux value should be configured in GMUX register and the lower 2 bits should be configured in the MUX register

    For example, to configure the mux option 9 (b1001) for GPIO56. 

    GpioCtrlRegs.GPBGMUX2.bit.GPIO56 = 0x2;

    GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 0x1;

    I would highly recommend you use the SysConfig tool for pinmuxing and basic peripheral initialization. It autogenerates the init code from the configurations done by the user through a GUI. The generated code uses driverlib functions instead of bitfield registers.

    Regards,

    Veena