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.
Tool/software: Code Composer Studio
Hi,
When I was writing to DAC102S085, for example I write a word 0x5E1C to set DAC_B to output a voltage, the value is shifty, not stable.
Next is my program and waveform.
Please help me how can I resolve it.
#include <msp430.h>
unsigned char RXData = 0;
unsigned char TXData;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD;
P1SEL0 |= BIT5 | BIT6 | BIT7; // set 3-SPI pin as second function
P1DIR |= BIT1;
P1OUT |= BIT1;
UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCA0CTLW0 |= UCMST|UCSYNC|UCMSB|UCCKPL|UCCKPH; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTLW0 |= UCSSEL__ACLK; // Select ACLK
UCA0BR0 = 0x02; // BRCLK = ACLK/2
UCA0BR1 = 0; //
UCA0MCTLW = 0; // No modulation
UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
while(1)
{
P1OUT &= ~ BIT1;
UCA0IE |= UCTXIE;
__bis_SR_register(LPM0_bits | GIE); // enable global interrupts, enter LPM0
TXData = 0x1C;
UCA0IE |= UCTXIE; // Enable TX interrupt
__bis_SR_register(LPM0_bits | GIE); // enable global interrupts, enter LPM0
TXData = 0x5E;
__delay_cycles(100);
P1OUT |= BIT1;
__delay_cycles(60);
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA0IV,USCI_SPI_UCTXIFG))
{
case USCI_NONE: break; // Vector 0 - no interrupt
case USCI_SPI_UCRXIFG:
RXData = UCA0RXBUF;
UCA0IFG &= ~UCRXIFG;
__bic_SR_register_on_exit(LPM0_bits);// Wake up to setup next TX
break;
case USCI_SPI_UCTXIFG:
UCA0TXBUF = TXData; // Transmit characters
UCA0IE &= ~UCTXIE;
break;
default: break;
}
Hi Daojia,
Thank you for your query. The SPI waveform looks fine. Although a zoomed-in version will help analyze the timing better. I am assuming that some other circuit is pulling the output low periodically. It might be pulling either the DAC output or the reference input.
Could you please share the DAC part of your schematics? If there are confidentiality issues, we can take the discussion to email.
Regards,
Uttam Sahu
Applications Engineer, Precision DAC
Hi, Uttam
The DAC part of my schematic as below:
The function of DAC102S085 is just used to generate two threshold voltage about 3.7V(DAC_A) and 4.2V(DAC_B).
Then use 3.7V and 4.2V to be as the comparing voltage in LM339 as below:
I just want if the two input voltage at 5,6 and 7,8 pin is in the range: 3.7V~4.2V, the out ping will pull up to 5V.
A zoomed-in version picture is below: the first picture is writing 0x1C60 to DAC102S085.
The second picture is writing 0x5E0C to DAC102S085.
When I was detecting the output voltage of DAC102S085, it didn't equal to the value I want set.
Daojia
Hi, Uttam
Add a information that I used MSP_EXP430FR2311 lanuchpad to set SPI 3wire communication with DAC102S085.
Daojia
Hi Daojia,
Apologies for the late response. Is it possible for you to change the SPI mode to mode 1 and try? This is currently in mode 2.
Regards,
Uttam