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.

Getting problem while communicating digital pot with tm4c123gh6pm

Other Parts Discussed in Thread: TM4C123GH6PM

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...

  • Hello Asha

    1. Why configure it as a GPIO Output when it is going to be SSI Pins?
    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_5); //SCK, SO

    2. Follow up SISDataPut with a SSIDataGet to ensure the RXFIFO is flushed (even though it is not really receiving anything fromt he slave device except 0's)

    Regards
    Amit
  • Asha Antonyraj said:
    i(sic) I am getting a problem its not working.

    Again - "unguided posters" present, "Crystal clear detail!"   Does not working mean: wrong color, does not fit, response is too fast/slow or in error?   (what is that error?)

    Indeed his coding needs work - yet are not (multiple) other potential factors in the mix?   Following may add needed insight:

    a)  Is his external device fully/properly powered?   (i.e. can his LPad power the external device/board?)

    b)  That digital pot may be powered from 5V or 3V3.   But - as Vih is spec'ed @ 0.7Vdd - if powered from 5V - the LPad may not quite reach that minimum input level!

    c)  Has each/every connection been properly "ohmed out" (checked for continuity) and adjacent pin shorts?

    d)  What is the method employed to reach that, "its not working" conclusion?   Method & equipment used adds value to any "self-diagnosis" - especially such a broad one.

    The MCU may not (always) be the "guilty party."    As long stated/( urged even) beginning posters may not be, "up to task" in their identification and presentation of very necessary data!   (Some) guidance (evidenced here) may prove helpful...    (Alas - this reporter - no longer - holds his breath...)