I am looking for a sample code which explains me the SPI interface between MSP430F5438a and ADS1224. .
It would be great if you could attach some working files.
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.
Welcome to the forum! Unfortunately I'm not aware of any MSP430 example code for the ADS1224. The code will depend on the manner in which you want to use the part. For example, if you want to poll DRDY/DOUT pin for a low state you will need to have 25 SCLKs to forced the pin high. This is outside the MSP430 SPI device peripheral's mode of operation which uses byte transfers. In this case you would need to bit-bang the port instead of using the SPI peripheral.
If you use an interrupt driven system, then you could use the SPI peripheral. In this case, when DRDY/DOUT transitions from a high to low state you read the data from the device. You need to send three bytes of NOP and read back the data to a signed 32 bit integer. If you think of the integer as an array, you would save the contents with MSB first, and LSB as the last of the three bytes. The timing should follow Figure 25 of the datasheet.
One method that could be used for the data retrieval could be similar to as follows:
u8 *cptr=(u8 *)(&_code); //_code is a signed 32 bit integer, and cptr is a pointer to the _code variable as an unsigned 8 bit value
// get 3 bytes as data word is 24 bits
// sign extend the value as needed
To set up the port peripheral, you would need to do something similar to as follows:
//ACLK = ~32.768kHz, MCLK = SMCLK = DCO ~ 1048kHz. BRCLK = SMCLK/2
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x02; // /2
UCA0BR1 = 0; //
UCA0MCTL = 0; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
I did not verify that the clock polarity is correct for this example, so you will need to verify all settings are conforming to the timing requirements. I would suggest getting familiar with the MSP430F54328A datasheet, user guide and the header file used for your compiler. The above code is based on IAR and UCA0 peripheral. If you use a different peripheral you will need to adjust the naming appropriately.
Thanks for the reply, it helped a lot!
I wrote the routine for an interrupt driven system, and without the software I am getting the DRDY pulse indicating that the data is ready! I am connecting this pin from EVM to P1.4 of MSP430F5438A board, to give an interrupt, and configuring that pin for hi to low interrupt, with a pulled up resistor. but, MSP is not geting interrupted as it is not entering the ISR. Can you suggest something.
I am having a problem with my code. After I sign extend the cptr how am going to use it? lets say I want to display the number on the hyperterminal, that is the integer equivalent of 24 bit number sent by adc. I am having some problems with that.
If you have a number and you want to redisplay it in another format (like ASCII) then you will need to convert the value that is representative of the original. There are a number of ways that this can be handled. The ASCII representation is a byte value of the printable character. If you start with an integer value, each digit must be converted to ASCII. You can see from the ASCII table that '0' is decimal value 48. With this method you can store each digit of the integer value into an array of characters that are printable ASCII.
A similar method is done by using the hex value instead of the integer value. This simplifies the conversion process as you can just shift grouping of four bits and convert them to the ASCII representation from 0 to 15 in each group. I prefer this method as it is easier to convert back and forth from ASCII and will always be in a predefined format. However, it is not as easy to just read the value.
As far as actually being able to read the value on hyperterminal ( or some other terminal program), you will need to send the ASCII character out one of the serial ports (TX/RX), and either convert it to RS232 or have a serial(TX/RX) to USB converter like the TI TUSB3410.
I am having a problem with the ads1224evm I am using. The ADC is able to generate the DRDY pulse, but not sending the data even when the clock signals on SPI interface are sent. I checked it on the CRO and confirmed the same. I tried changing the reference volatge to external reference of 2.5 volts, but it is not working properly/
All digital pins must be connected to a valid digital high or low. What value of MUX input settings are you using? What does the data look like when you send the SCLKs? Can you send me some scope pictures of the communication? What values of data are you expecting to see? Do you have all the necessary supply voltages, in particular +5V for AVDD?
Thanks for the reply, I am connecting the ADC differential input with the negative pin grounded and to the positive pin I am giving a square wave pulse of peak to peak amplitude of 1 volts, being offset by 1 volt so the it is bounded between 2v-1v to avoid giving negative voltage to the input. I testes it earlier and was giving the values accurate for supply given, but now the after the DRDY pulse, the pin goes to zero when the clocks are sent. The yellow is the probe at DRDY/DOUT pin and green is SCLK. I am connecting the MUX inputs to the output of P10.0 and P10.1 of MSP430F5438A board.
I am able to get +5v at AVDD of the chip. I just now removed the external Vref and used the switches on board to get +2.5v as Vref+ and grounded the Vref- pin, but the 2.5v test point is showing 0.845v, but the pin 20 of chip shows AVDD= +5 v. Also the voltage across C18 is 0.4 v when onboard switches are used to generate Vref I am not able to understand the reason behind it as I was getting the proper voltages in my last run. If the zener diode and opa350 assembly is bypassed and external Vref is given then the voltage across C18 is 2.5 v but output in both the cases(with and without external Vref) is still zero.
But were you actually connected to the analog ground? The board has two ground connections. Where do have the supply connections connected to on the EVM? Where do you have the jumpers connected on J4? If you can't get the proper voltages from the on board reference then something is damaged or something is not connected properly.
Yes I was connected to the analog ground. I have connected the DVDD of +3.3 v to pin 9 of J3, AGND to pin 5, +5VA to pin 3 and DGND to pin6 of J3. and I am taking analog i/p on port 2. On J4 jumpers are placed on 1-2, 3-4, 7-8 and 11-12, exactly same thing has happened to the second EVM board which I have which is not giving the proper output. Is there any specific problem which can cause this?
You will get a zero reading with the input switches set in the middle or right hand positions. I'm assuming that the switch settings for the input are in the left hand position. I still have concerns as to why you were having problems with the on board reference. What were the switch positions for the reference when you were getting the strange readings?
One thing I would try is to remove the waveform from the inputs and just place a DC value at the inputs to see what you get for this case.
Yes the switches for input are in left position taking the external inputs. I tried with dc input too but there was no change in the output. The switch positions for Vref+ was +2.5v and for Vref- was 0v. Also irrespective of switch positons of Vref the +2.5v Test point shows the reading of 0.843v.
The testpoint reading is more like the diode is being forward biased instead of reverse biased. If you supply connections are correct, then something has been damaged along the way. If one of the reference components has been damaged, then most likely the ADS1224 is also damaged.
I would look at each stage and try to discover which parts have failed, or are shorted. One last thing to check on the digital side is to place a scope probe at RA2 and measure on each side of the resistor to make sure there isn't something shorting the DOUT line on the micro side of things.