Tool/software: Code Composer Studio
Hello
I have a problem with receiving data from the thermistor. I use IDAC to direct current to the sensor, and ADC`s AIN2/AIN3 inputs to receive data from the the sensor. Gain and IDAC current setting didn`t help. Always get incorrect values.
I use manual mode with counter (without DRDY).
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
FRCTL0 = FRCTLPW | NWAITS_1;
P4DIR = BIT0; //setting P1.0 as output
P4OUT = BIT0;
CS_init ();
UART_init();
reset();
reg0_init();
reg1_init();
reg2_init();
reg3_init();
UART_transmit();
}
void CS_init (void)
{
CSCTL0_H = CSKEY_H;
CSCTL1 = DCOFSEL_3 | DCORSEL;
CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;
CSCTL0_H = 0;
}
void UART_init(void)
{
P4SEL0 |= BIT1 | BIT2;
P4SEL1 |= BIT1 | BIT2;
UCA3CTLW0 = UCSWRST;
UCA3CTLW0 |= UCSSEL__SMCLK;
UCA3BRW = 54;
UCA3MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
UCA3CTLW0 &= ~UCSWRST;
}
void reset(void)
{
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x06;
while (!(UCA3IFG & UCTXIFG));
}
void reg0_init(void)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x20;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x40;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x78;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x20;
while (!(UCA3IFG & UCTXIFG));
while (!(UCA3IFG & UCRXIFG));
rcv = UCA3RXBUF;
}
void reg1_init(void)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x22;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x42;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x88;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x22;
while (!(UCA3IFG & UCTXIFG));
while (!(UCA3IFG & UCRXIFG));
rcv = UCA3RXBUF;
}
void reg2_init(void)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x24;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x44;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x47;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x24;
while (!(UCA3IFG & UCTXIFG));
while (!(UCA3IFG & UCRXIFG));
rcv = UCA3RXBUF;
}
void reg3_init(void)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x26;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x46;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0xC0;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x26;
while (!(UCA3IFG & UCTXIFG));
while (!(UCA3IFG & UCRXIFG));
rcv = UCA3RXBUF;
}
void UART_transmit(void)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x08;
while(1)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x55;
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = 0x10;
delay_ ();
while (!(UCA3IFG & UCTXIFG));
while (!(UCA3IFG & UCRXIFG));
rcv = UCA3RXBUF;
}
}