Other Parts Discussed in Thread: TM4C123GH6PZ, LM3S6965
HI..i'm interfacing External DAC (AD5791) With TM4C123GH6PZ through ssi communication..crystal frequency is 8mhz...I want to set 35Mhz as an ssi0clk.
my question is how exactly set 35Mhz ???
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.
Other Parts Discussed in Thread: TM4C123GH6PZ, LM3S6965
HI..i'm interfacing External DAC (AD5791) With TM4C123GH6PZ through ssi communication..crystal frequency is 8mhz...I want to set 35Mhz as an ssi0clk.
my question is how exactly set 35Mhz ???
Hi..I have confusion in thsi function.
I'm using 8 Mhz crystel fresuency..n i want to set i mhz as ssiclk..
SSIConfigSetExpClk(SSI3_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, SysCtlClockGet()/8, 16);
Is this correct to set 1Mhz as crystal frequency??
Hi..I have confusion in thsi function.
I'm using 8 Mhz crystel fresuency..n i want to set i mhz as ssiclk..
SSIConfigSetExpClk(SSI3_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, SysCtlClockGet()/8, 16);
Is this correct to set 1Mhz as ssiclk??
Hi,
Even if the data sheet is giving you something high, you don't need to go so fast - this chip can be used with some other micros/DSPs which can be faster. Mainly depends on what you need - I mean the application you develop. For a waveform to generate, you may go high with frequency, but only if the waveform is not distorted, due to ignoring the settling time.
About your settings - depends on what you set for the main clock - if you use the PLL and get the 80MHz, the expression used will give you 10MHz - still OK, if the system clock is set to 8MHz, then … you got it of coarse. In case you have doubts, use a long variable to catch up the value returned by SysCtlGet() and verify/set the clock for SSI.
And also about the settings - as I read this DAC is 20 bits, so configure the SSI to send out 10 bits at the time, so you will need two words to send - and setting the frequency to 20MHz, 20 bits will give you at least 1 microsecond time to settle for the output (and MOTO_MODE_0 may not work in this case - see the data sheet what other mode is supported)
Petrei
Petrei said:And also about the settings - as I read this DAC is 20 bits, so configure the SSI to send out 10 bits at the time, so you will need two words to send -
20 bit DAC but each control word is 24 bits. I've only see a small number of devices that were not a multiple of 8 bits and I think only one that did not work with 8 bit multiples and I doubt it exists anymore. There are very good reasons SPI devices near universally support 8 bit multiples.
Generally, I have found no reason to ever set an SPI peripheral to other than 8 bits.
Robert
Robert Adsett said:Generally, I have found no reason to ever set an SPI peripheral to other than 8 bits.
Hi Robert, it can make sense just if your external register is longer/shorter than 8 bit, many SPI can transmit two bytes and some perform variable length, ex if you are transmitting/receiving 12 bit to/from an FPGA register you can save time sending/recv just what are in need. Standard device need a uniform write to coexist alltogether.
Anyway I suppose Petrei was adapting simple word to a beginner than specify sending 3 or 4 bytes of data with all endianess background...
As I said I have only ever seen maybe one external SPI device that did not work with 8 bits. Such devices are as rare as hen's teeth in my experience.
FPGA is another matter but even in that case it is a simple matter for them to ignore a few extra bits at the begining and most implementations do simply because that is the easiest method to work with (just look at the last n bits shifted in).
Standard practice is 8 bit multiples. I don't remember the last device I've seen that did not support 8 bits.
Robert
Roberto Romano said:Anyway I suppose Petrei was adapting simple word to a beginner than specify sending 3 or 4 bytes of data with all endianess background...
Heh, two twelves still have an endianness. It might be more complicated to understand now since you've split a byte across words. Even a single word of more than one byte has endian issues and leave us not forget the endian issue within a byte. MSb first or LSb first?
Robert
Hi,
Yes, you are right - the command word is 24 bits, so three times 8 bits to be transmitted.
I had difficulties with the data sheet, not opening fully in browser or pdf reader - never happened with a document from AD up to now.
Petrei
Hi..I'm interfacing External DAC (ad5791) with Tm4c123gh6pz through SSI1..I'm not getting the output...Please can any one help me If i have done any mistake in communication configuration..
#include <string.h>
#include "inc/lm4f232h5qc.h"
#include "inc/hw_memmap.h"
#include "driverlib/pin_map.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/softssi.h"
#include "utils/uartstdio.h"
#include "driverlib/rom.h"
#include "driverlib/ssi.h"
#include "inc/hw_gpio.h"
#define GPIO_PD0_SSI1CLK 0x00030002
#define GPIO_PD1_SSI1FSS 0x00030402
#define GPIO_PD3_SSI1TX 0x00030C02
#define GPIO_PD2_SSI1RX 0x00030802
void Setup_SSI();
#define NUM_SSI_DATA 2
unsigned long ulDataTx[NUM_SSI_DATA]; // An array of 2 data bytes to be Tx
unsigned long ulindex;
int main()
{
Setup_SSI();
while(1)
{
ulDataTx[0] = 0x200012;
ulDataTx[1] = 0x1fffff;
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x00);//to make sure the sync high
for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
{
SSIDataPut(SSI1_BASE, ulDataTx[ulindex]);
while(SSIBusy(SSI1_BASE)){}
// Receive the data using the "blocking" get function.
//while(SSIBusy(SSI3_BASE)){}
}
}
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x02);//to make sure the sync high
}
void Setup_SSI()
{
// Configures the system clock, the LM3S6965 has a 8MHz crystal onboard
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 ); //RESET PIN,CLR,LDAC
// Enable the SSI1 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
// The SSI0 peripheral is on Port D and pins 0,1,AND 3.
// Enable GPIO port D
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
// This function/s configures the pin muxing on port D pins 2,3,4 and 5
// It uses the values DEFINED at the top of the program and takes 1 parameter
GPIOPinConfigure(GPIO_PD0_SSI1CLK);
GPIOPinConfigure(GPIO_PD1_SSI1FSS);
GPIOPinConfigure(GPIO_PD2_SSI1RX);
GPIOPinConfigure(GPIO_PD3_SSI1TX);
// Configures the pins for use by the SSI, takes 2 parameters
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0|GPIO_PIN_2 |GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1); // SYNC
// Configures the SSI port for SPI master mode, it takes 6 parameters
SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3,
SSI_MODE_MASTER, SysCtlClockGet()/8, 16);
// Enables the SSI0 module
//GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_1, 0x02);
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x02);//to make sure the sync high
SSIEnable(SSI1_BASE);
}
Hello Rashmi,
1. Can you please check if the crystal is indeed 8MHz on your board. As far as I know Launcpad and DK kits came with 16MHz crystal for TM4C123
2. The configuration is fine, but have you checked that the test code is going into the while(1) loop? In other words is there not a Fault being triggered?
Regards
Amit
Hello Rashmi,
If the clock pulses and data is on the scope then can you compare it against the ADS data sheet to see if it is as per expectation of ADS DAC? Also do make that the ADS is wired correctly, i.e. it's supply, grounf and other control pins are as per the requirement of the ADS Device.
Regards
Amit
Hi...i'm interfacing extternal DAC (ad5791) with sss1 of lm4f232h5qc.
crystal frequency = 8Mhz
sssclk = 1m hz..
but i'm not getting output..:(.even i have checked hardware connection.all are k...can you please any one help me if i would have done any mistake in below code??
#include <string.h>
#include "inc/lm4f232h5qc.h"
#include "inc/hw_memmap.h"
#include "driverlib/pin_map.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/softssi.h"
#include "utils/uartstdio.h"
#include "driverlib/rom.h"
#include "driverlib/ssi.h"
#include "inc/hw_gpio.h"
#define GPIO_PD0_SSI1CLK 0x00030002
#define GPIO_PD1_SSI1FSS 0x00030402
#define GPIO_PD3_SSI1TX 0x00030C02
#define GPIO_PD2_SSI1RX 0x00030802
void Setup_SSI();
/*void delay(int val)
{
int i,j;
for(i=0;i<10;i++)
{
for(j=0;j<val;j++)
{
}
}
}*/
#define NUM_SSI_DATA 9
char ulDataTx[NUM_SSI_DATA]; // An array of 2 data bytes to be Tx
char ulDataRx[NUM_SSI_DATA]; // An array of 2 data bytes to be Tx
char ulindex;
int main()
{
Setup_SSI();
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x02);//TO MAKE SURE SYNC IS HIGH INITIALLY
//delay(25);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_4,0x00); //TO MAKE REST PIN HIGH
//delay(25);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_4,0x10); //TO MAKE REST PIN HIGH
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_5,0x00); //TO MAKE CLEAR PIN HIGH
//delay(25);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_5,0x20); //TO MAKE CLEAR PIN HIGH
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_6,0x40); //TO MAKE LDAC PIN HIGH
while(1)
{
ulDataTx[0] = 0x20;
ulDataTx[1] = 0x00;
ulDataTx[2] = 0x12;
ulDataTx[3] = 0x30;
ulDataTx[4] = 0x00;
ulDataTx[5] = 0x00;
ulDataTx[6] = 0x1f;
ulDataTx[7] = 0xff;
ulDataTx[8] = 0xff;
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x00);//to make sure the sync high
//delay(25);
for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
{
SSIDataPut(SSI1_BASE, ulDataTx[ulindex]);
while(SSIBusy(SSI1_BASE)){}
// Receive the data using the "blocking" get function.
//while(SSIBusy(SSI3_BASE)){}
}
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x02);//to make sure the sync high
// delay(25);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_6,0x00); //MAKE LDAC PIN LOW TO OUTPUT NEW DATA (LOW-HIGH TRANS OUTPUT NEW DATA)
// delay(25);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_6,0x40); //MAKE LDAC PIN HIGH TO OUTPUT NEW DATA
}
}
void Setup_SSI()
{
// Configures the system clock, the LM3S6965 has a 8MHz crystal onboard
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 ); //RESET PIN,CLR,LDAC
// Enable the SSI1 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
// The SSI0 peripheral is on Port D and pins 0,1,AND 3.
// Enable GPIO port D
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
// This function/s configures the pin muxing on port D pins 2,3,4 and 5
// It uses the values DEFINED at the top of the program and takes 1 parameter
GPIOPinConfigure(GPIO_PD0_SSI1CLK);
GPIOPinConfigure(GPIO_PD1_SSI1FSS);
GPIOPinConfigure(GPIO_PD2_SSI1RX);
GPIOPinConfigure(GPIO_PD3_SSI1TX);
// Configures the pins for use by the SSI, takes 2 parameters
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0|GPIO_PIN_2 |GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1); // SYNC
// Configures the SSI port for SPI master mode, it takes 6 parameters
SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3,
SSI_MODE_MASTER, SysCtlClockGet()/8, 8);
SSIEnable(SSI1_BASE);
}
Rashmi yc said:Hi...i'm getting clock pulses and data in oscilloscope..
Good, so it is less likely to be a micro issue and more an interface issue. The next step as Amit says is to check the signal you are sending and verify that it matches what the IC expects. Check clock, data, chip selects and enables. Make sure they meet the timing requirements. Check your power and grounds. Make sure you have the right bit order and that you are clocking on the right edge.
If all that checks then you need to move on to the initialization sequennce for the D/A.
Robert
Thanks Petrei. Because it is the same thread I am moving it here,
Hello Rashmi,
Please do not run the same post on forums centric to TM4C or LM4F devices.
Regards
Amit
Hi,
Reading your last post, I have these observations:
Petrei
Hello Rashmi,
Look at the timing diagrams for both the ADS and TM4C devices side by side to understand the timing aspect of the communication. It is not as tough as you may think.
Also clearly document yourself what the SW code structure should be for communicate before coding it. And what each step of the code execution must result in. That will help you a lot when running the code and looking at the scope.
Regards
Amit
k k Thank you for your support..i have gone through the timing diagram of both TM4C N DAC...Can you tell me how to understand the timing diagram means mode of operation?i have red it but still i have confusion..
Hi,
You may try both - if they specify mode3, then mode3, but please be sure we speek the same conventional notation there may be some inversions...
Usually two modes are accepted (most devices uses mode0 and mode3, there are exceptions also).
Petrei
Hi...no output :(
#include <string.h>
#include "inc/lm4f232h5qc.h"
#include "inc/hw_memmap.h"
#include "driverlib/pin_map.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/softssi.h"
#include "utils/uartstdio.h"
#include "driverlib/rom.h"
#include "driverlib/ssi.h"
#include "inc/hw_gpio.h"
#define GPIO_PD0_SSI1CLK 0x00030002
#define GPIO_PD1_SSI1FSS 0x00030402
#define GPIO_PD3_SSI1TX 0x00030C02
#define GPIO_PD2_SSI1RX 0x00030802
void Setup_SSI();
void writead5791();
#define NUM_SSI_DATA 3
long ulindex;
unsigned long writeCommand[NUM_SSI_DATA];
unsigned long readCommand[NUM_SSI_DATA];
int main()
{
Setup_SSI();
while(1)
{
writead5791(0x0200012);
writead5791(0x010cfff);
writead5791(0x0400001);
}
}
void Setup_SSI()
{
// 8MHz crystal onboard
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
// Enable the SSI1 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
// The SSI0 peripheral is on Port D and pins 0,1,AND 3.
// Enable GPIO port D
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
// This function/s configures the pin muxing on port D pins 2,3,4 and 5
// It uses the values DEFINED at the top of the program and takes 1 parameter
GPIOPinConfigure(GPIO_PD0_SSI1CLK);
GPIOPinConfigure(GPIO_PD1_SSI1FSS);
GPIOPinConfigure(GPIO_PD2_SSI1RX);
GPIOPinConfigure(GPIO_PD3_SSI1TX);
// Configures the pins for use by the SSI, takes 2 parameters
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0|GPIO_PIN_2 |GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1); // SYNC
// Configures the SSI port for SPI master mode, it takes 6 parameters
SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_2,
SSI_MODE_MASTER, SysCtlClockGet()/8, 8);
SSIEnable(SSI1_BASE);
}
void writead5791(long value)
{
writeCommand[0] = (value & 0xFF0000) >> 16;
writeCommand[1] = (value & 0x00FF00) >> 8;
writeCommand[2] = (value & 0x0000FF);
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x00); //to make sure the sync low
for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
{
SSIDataPut(SSI1_BASE, writeCommand[ulindex]);
while(SSIBusy(SSI1_BASE)){}
SSIDataGet(SSI1_BASE, &readCommand[ulindex]);
}
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x02); //to make sure the sync high
}
.
Hello Rashmi,
I will ask you to add the line
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0x02); //to make sure the sync high
after the
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1); // SYNC
so that the SYNC signal is High before the next data transfer function is called. (This is not the issue but would help in the debug as below)
When you mention no output, then is there no CLK on the scope or does the FSS Signal not go Low? If possible take a snapshot of the scope transaction
Regards
Amit
Hi Amit..i'm using quadrature encoder for one of my application..i have posted my doubt on forum..but i did't get reply..If you known for that thing kindly reply to me.Thanks in advance
Thanks n Regards