HI
I am using tm4c123gh6pm Launchpad.I try to interface digital pot mcp41010 Via SSI communication.but i am getting a problem below i paste my code plz verify and tell is there any mistake in that
#include <stdint.h>
#include <stdbool.h>
#include "C:\Users\admin\inc\hw_types.h"//"inc/hw_types.h"
#include "C:\Users\admin\inc\hw_memmap.h"//"inc/hw_memmap.h"
#include "C:\Users\admin\driverlib\sysctl.h"//"driverlib/sysctl.h"
#include "C:\Users\admin\driverlib\gpio.h"//"driverlib/gpio.h"
#include "C:\Users\admin\inc\tm4c123gh6pm.h"
#include "C:\Users\admin\driverlib\timer.h"
#include "C:\Users\admin\driverlib\interrupt.h"
#include "C:\Users\admin\driverlib\ssi.h"
unsigned int d;
#define CS GPIO_PIN_1
void delay_ms(int del)
{
del=((SysCtlClockGet()/3)*del/1000);
SysCtlDelay(del);
}
void ssi_init()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralReset(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_5);
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1,2);
GPIOPinConfigure(0x00000802); //sck
GPIOPinConfigure(0x00001402); //SO
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;
delay_ms(500);
SSIDataPut(SSI0_BASE,0x11);
SSIDataPut(SSI0_BASE,0x00);while(SSIBusy(SSI0_BASE));
delay_ms(100); //mcp write
SSIDataPut(SSI0_BASE,0xFF);
SSIDataPut(SSI0_BASE,0x00); while(SSIBusy(SSI0_BASE));
delay_ms(100);
//SSIDataPut(SSI0_BASE,0x00);while(SSIBusy(SSI0_BASE)); dly(100); //value to be written
GPIOPinWrite(GPIO_PORTE_BASE, CS, 2); //CS = 1;
}
int main()
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1);//CS
ssi_init();delay_ms(50);
while(1)
{
mcp(10);
}
}
i continuously getting an output at mcp 2.5v only for all the values