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.
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.
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 UCA0TXBUF=0xff; while(!(UCA0IFG&UCRXIFG)); cptr=UCA0RXBUF;
UCA0TXBUF=0xff; while(!(UCA0IFG&UCRXIFG)); cptr=UCA0RXBUF;
UCA0TXBUF=0xff; while(!(UCA0IFG&UCRXIFG)); cptr=UCA0RXBUF;
// 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.
We are glad that we were able to resolve this issue, and will now proceed to close this thread.
If you have further questions related to this thread, you may click "Ask a related question" below. The newly created question will be automatically linked to this question.
In reply to Bob Benjamin:
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.
In reply to Kedar Joshi:
Are you making sure that the interrupts are enabled? If you send me your setup code for the interrupts and the enable instruction I'll take a look at it.
There was a bug in my code, but I was able to get it working. Thanks for your help.
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.
Are you absolutely sure that the MUX selection matches the inputs you are using?
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.