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.

TM4C123GXl with AD5206 Digital Potentiometer

I am trying to use a TM4C123GXL to control an AD5206 digital potentiometer, but I can't get the spi communication to work.  

Could you help me with this issue? Here is my test code that is supposed to cycle all the digipots from low to high.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ssi.h"
#include "inc/hw_types.h"
#include "driverlib/ssi.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"


int main(void)
{
	uint32_t channel;
	uint32_t level;

	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_3);
	GPIOPinConfigure(GPIO_PA5_SSI0TX);
	GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_3|GPIO_PIN_2);

	SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 8);
	SSIEnable(SSI0_BASE);

	while(1)
	{
    	for (channel = 0; channel < 6; channel++)
    	{
    		for (level = 0; level < 255; level++)
    		{
    			GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0x00);
    			SSIDataPut(SSI0_BASE, channel);
    			SSIDataPut(SSI0_BASE, level);
    			GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0x40);
    			while(SSIBusy(SSI0_BASE))
    			{
    			}

    		}
    	}

	}

}

Thanks,
Gerald

  • Gerald Vandermeir said:

    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_3);

    GPIOPinConfigure(GPIO_PA5_SSI0TX);

    GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_3|GPIO_PIN_2);

    You've given, "GPIO_PIN_3" multiple personalities - have you not?

    Later - you (expect) that pin to "revert" to GPIO: "GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0x00);"   Was it not changed to an SSI Type?   Have you been consistent?   What's a pin to do?

    And - GPIO_PIN_3 is unlikely to toggle high w/0x40!   (that toggles GPIO_PIN_6 - does it not?   0x08 seems better choice - after that pin is set/typed as GPIO!

  • Merci monsieur - much appreciated.

    Do keep your interconnect leads short and insure that a common ground between your LPad and (assumed) digital pot breadboard is implemented & maintained.

    Slower speeds in the beginning prove best - once test/verified - (only) then is the time to seek higher SPI speed.