Hi,
i am using digital pot MCP(41010) while I am trying to communicate this with tm4c123gh6pm by using SSI communication i am getting a problem its not working.here i attached my code
#include<stdint.h>
#include<stdbool.h>
#include<hw_memmap.h>
#include<hw_types.h>
#include<sysctl.h>
#include<gpio.h>
#include<ssi.h>
#define CS GPIO_PIN_1
void dly(unsigned int ms)
{
ms=(SysCtlClockGet()/3.0)*ms/1000;
SysCtlDelay(ms);
}
void ssi_init()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_5); //SCK, SO
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2);//CS
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_PIN_1);
GPIOPinConfigure(0x00000802); //sck
GPIOPinConfigure(0x00001402); //SO
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_5);
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 200000, 16);// defines base, System clk, Mode 0 = SPH = SPO = 0,Master, 125 KHz, no. of bits = 8 = 1 byte transfer
SSIEnable(SSI0_BASE); //enables SSI
}
void mcp(unsigned char dat)
{
GPIOPinWrite(GPIO_PORTE_BASE, CS, 0); //CS = 0;
dly(500);
SSIDataPut(SSI0_BASE,0x11);SSIDataPut(SSI0_BASE,0x00);while(SSIBusy(SSI0_BASE)); dly(100); //mcp write
SSIDataPut(SSI0_BASE,0xFF);SSIDataPut(SSI0_BASE,0x00); while(SSIBusy(SSI0_BASE)); dly(100);
//SSIDataPut(SSI0_BASE,0x00);while(SSIBusy(SSI0_BASE)); dly(100); //value to be written
GPIOPinWrite(GPIO_PORTE_BASE, CS, 2); //CS = 1;
}
void main()
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
ssi_init();dly(200);
while(1)
{
mcp(0);
}
}
above is my code plz chk my code is there any mistakes in that...highlighted portions are SSI initialization and digital pot part...