Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62446

Forum Post: RE: MSP430FR5949 Clock Speed

$
0
0
Hi Caleb, I'm communicating with the DAC through SPI and I can see the output wave when I scope it however I can't output it at higher frequencies. Here is the code that I am using. I was unable to copy and paste the syntax highlighter code it wouldn't insert the code with the colors for some reason. Thank you for your help! #include volatile unsigned char TXDATA; int sawtooth[150] = {0x2,0x3,0x5,0x7,0x9,0xa,0xc,0xe,0xf,0x11,0x13,0x14,0x16,0x18,0x1a, 0x1b,0x1d,0x1f,0x20,0x22,0x24,0x25,0x27,0x29,0x2b,0x2c,0x2e,0x30,0x31,0x33, 0x35,0x36,0x38,0x3a,0x3c,0x3d,0x3f,0x41,0x42,0x44,0x46,0x47,0x49,0x4b,0x4d, 0x4e,0x50,0x52,0x53,0x55,0x57,0x58,0x5a,0x5c,0x5e,0x5f,0x61,0x63,0x64,0x66, 0x68,0x69,0x6b,0x6d,0x6f,0x70,0x72,0x74,0x75,0x77,0x79,0x7a,0x7c,0x7e,0x80, 0x81,0x83,0x85,0x86,0x88,0x8a,0x8b,0x8d,0x8f,0x91,0x92,0x94,0x96,0x97,0x99, 0x9b,0x9c,0x9e,0xa0,0xa2,0xa3,0xa5,0xa7,0xa8,0xaa,0xac,0xad,0xaf,0xb1,0xb3, 0xb4,0xb6,0xb8,0xb9,0xbb,0xbd,0xbe,0xc0,0xc2,0xc4,0xc5,0xc7,0xc9,0xca,0xcc, 0xce,0xcf,0xd1,0xd3,0xd5,0xd6,0xd8,0xda,0xdb,0xdd,0xdf,0xe0,0xe2,0xe4,0xe5, 0xe7,0xe9,0xeb,0xec,0xee,0xf0,0xf1,0xf3,0xf5,0xf6,0xf8,0xfa,0xfc,0xfd,0xff}; int sin[10] = {0x80,0xca,0xf9,0xf9,0xca,0x80,0x35,0x6, 0x6,0x35,0x80}; void SPI_DATA(unsigned int a); void SPI_TRANSFER(char TXDATA); int i = 0; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer // Configure one FRAM waitstate as required by the device datasheet for MCLK // operation beyond 8MHz _before_ configuring the clock system. //FRCTL0 = FRCTLPW | NWAITS_1; // Clock System Setup //CSCTL0_H = CSKEY >> 8; // Unlock CS registers //CSCTL1 = DCOFSEL_0; // Set DCO to 16MHz //CSCTL2 = SELS__DCOCLK; //CSCTL3 = DIVS__1; // Set all dividers //CSCTL0_H = 0; // Lock CS registers // Clock System Setup // Configure GPIO P2OUT |= BIT7; P2DIR |= BIT4 | BIT5 | BIT7; //P2.7 = dac cs P2SEL1 |= BIT4 | BIT5 | BIT6; //A1 CLK, SIMO, SOMI //PJSEL0 |= BIT4 | BIT5; // For XT1 // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Configure USCI_A0 for SPI operation UCA1CTLW0 = UCSWRST; // **Put state machine in reset** UCA1CTLW0 |= UCMST | UCSYNC | UCMSB | UCCKPH; // 3-pin, 8-bit SPI master // Clock polarity high, MSB UCA1CTLW0 |= UCSSEL__SMCLK; // ACLK UCA1BR0 = 0x00; // /2 UCA1BR1 = 0; // UCA1MCTLW = 0; // No modulation UCA1CTLW0 &= ~UCSWRST; // **Initialize USCI state machine** //UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt //TXData = 0x1; // Holds TX data while(1) { //UCA0IE |= UCTXIE; //__bis_SR_register(LPM0_bits | GIE); // CPU off, enable interrupts for(i = 0; i > 8; //send MSB P2OUT &= ~BIT7; //set CS low 0111 1111 SPI_TRANSFER(TXDATA); TXDATA = DAC; //send LSB SPI_TRANSFER(TXDATA); P2OUT |= BIT7; //set cs high } void SPI_TRANSFER(char TXDATA){ while(!(UCA1IFG & UCTXIFG)); UCA1TXBUF = TXDATA; // Transmit characters while(UCA1STATW & UCBUSY); //return UCA1RXBUF; }

Viewing all articles
Browse latest Browse all 62446

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>