Hi,
I am using the MSP430F2619 MCU.
I am trying to send data to the AD9834, there is an OCTAL BUFFER(74HC244) inbetween my MCU and AD9834,
I have connected the buffer to the MCU via the following pins:
(See Pic)
P3.1 (UCB0SIMO),
P3.2(UCB0SOMI),
P3.3(UCB0CLK),
P1.6(GPIO) for enable (active low enable), and
P2.1(CA3) for AD9834 reset.
Also i need to send three different words one after another to the AD9834 through the Buffer.
Ox2200 for ctrl reg
0xA000 for setting phase
0x4000 and 0x47DD for setting frequency.
Before i show the code, here are the USCI_B0__SPI register values.
BEFORE PROGRAM EXECUTION :
UCBOCTL0__SPI = 0x01
UCBOCTL1__SPI = 0x01
UCBOBRO__SPI = 0x00
UCBOBR1__SPI = 0x00
UCBOSTAT__SPI = 0x00
UCBORXBUF__SPI = 0x00
UCBOTXBUF__SPI = 0x00
AFTER PROGRAM EXECUTION:
UCBOCTL0__SPI = 0x69
UCBOCTL1__SPI = 0x80
UCBOBRO__SPI = 0x02
UCBOBR1__SPI = 0x00
UCBOSTAT__SPI = 0x20
UCBORXBUF__SPI = 0x00
UCBOTXBUF__SPI = 0x00
here's the code.
#include <msp430x26x.h>
unsigned char MST_Data,SLV_Data;
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
if (CALBC1_12MHZ ==0xFF || CALDCO_12MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_12MHZ; // Set DCO
DCOCTL = CALDCO_12MHZ;
for(i=2100;i>0;i--); // Wait for DCO to stabilize.
P1SEL |=0x40; // Switch off buffer
P3SEL |= 0x0E; // P3.3,2,1 option select
UCB0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; //3-pin, 8-bit SPI master
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 = 0x02; // /2
UCB0BR1 = 0; //
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCB0RXIE; // Enable USCI_A0 RX interrupt
P1OUT &= ~0x02; // Now with SPI signals initialized,
P1OUT |= 0x02; // reset slave
for(i=50;i>0;i--); // Wait for slave to initialize
UCB0TXBUF = MST_Data; // Transmit first character
_BIS_SR(LPM0_bits + GIE); // CPU off, enable interrupts
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCIA0RX_ISR (void)
{
volatile unsigned int i;
while (!(IFG2 & UCB0TXIFG)); // USCI_B0 TX buffer ready?
P1SEL |=0x00; // Switch-on/Enable buffer
for(i=100;i>0;i--);
P2SEL |=0x02; //Reset Sig gen
for(i=100;i>0;i--);
P2SEL |=0x00; //Remove Reset
for(i=100;i>0;i--);
UCB0TXBUF = 0x022; // Send MSB of Ctrl word
for(i=100;i>0;i--);
UCB0TXBUF = 0x00; // Send LSB of ctrl word
for(i=100;i>0;i--);
UCB0TXBUF = 0xA0; // Send MSB of phase value
for(i=100;i>0;i--);
UCB0TXBUF = 0x00; // Send LSB of phase value
for(i=100;i>0;i--);
UCB0TXBUF = 0x040; // Send MSB of M14 of freq reg
for(i=100;i>0;i--);
UCB0TXBUF = 0x00; // Send LSB of M14 of freq reg
for(i=100;i>0;i--);
UCB0TXBUF = 0x047; // Send MSB of L14 of freq reg
for(i=100;i>0;i--);
UCB0TXBUF = 0xDD; // Send LSB of L14 of freq reg
for(i=100;i>0;i--);
P1SEL |=0x40; // Switch-off/Disable buffer
for(i=30;i>0;i--); // Add time between transmissions to
} // make sure slave can keep up
I dont get any sine output from the AD9834.
I have the following doubts:
1) I am setting the contents of Bit Rate Control Register 0 and 1, as 0x02 and 0 respectively, is it right?
2) Has the buffer been enabled during the execution of the program?
3) Is the code in the ISR right?
4) My XTCLK is 12MHz, i am setting DCO as 12MHz, is it right?
5) Which lines of code are unnecessary?
I would be grateful, if someone could help me out.
Thanks.