Part Number: MSP432P401R
Tool/software: TI C/C++ Compiler
this is my code i got 540sample/sec at baud rate 460800 .How can i get 1K samples.
#include "ti/devices/msp432p4xx/inc/msp.h"
int main(void)
{
volatile unsigned int i, data;
//int data;
WDT_A->CTL = WDT_A_CTL_PW | // Stop watchdog timer
WDT_A_CTL_HOLD;
// Configure UART pins
P1->SEL0 |= BIT2 | BIT3; // set 2-UART pin as secondary function
// Enable eUSCIA0 interrupt in NVIC module
// NVIC->ISER[0] = 1 << ((EUSCIA0_IRQn) & 31);
// Sampling time, S&H=16, ADC14 on
ADC14->CTL0 = ADC14_CTL0_SHT0_6| ADC14_CTL0_SHP | ADC14_CTL0_ON | ADC14_CTL0_PDIV_2 | ADC14_CTL0_DIV_2 | ADC14_CTL0_CONSEQ_2 | ADC14_CTL0_SSEL_4 | ADC14_CTL0_MSC;
ADC14->CTL1 = ADC14_CTL1_RES_0; // Use sampling timer, 12-bit conversion results
// ADC14->CTL1 = 0x00000010;
ADC14->MCTL[0] |= ADC14_MCTLN_INCH_1; // A1 ADC input select; Vref=AVCC
P5->SEL1 |= BIT4; // Configure P5.4 for ADC
P5->SEL0 |= BIT4;
//ADC14->CTL0 |= 2;
ADC14->IER0 |= ADC14_IER0_IE0; // Enable ADC conv complete interrupt
SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; // Wake up on exit from ISR
// Configure UART
EUSCI_A0->CTLW0 |= EUSCI_A_CTLW0_SWRST; // Put eUSCI in reset
EUSCI_A0->CTLW0 = EUSCI_A_CTLW0_SWRST | // Remain eUSCI in reset
EUSCI_B_CTLW0_SSEL__SMCLK; // Configure eUSCI clock source for SMCLK
// Baud Rate calculation
// 12000000/(16*460800) = 1.6276
// Fractional portion = 0.627
// User's Guide Table 21-4: UCBRSx = 0x10
// UCBRFx = int ( (1.6276-1)*16) = 10
EUSCI_A0->BRW = 1; // 12000000/16/460800
EUSCI_A0->MCTLW = (10<< EUSCI_A_MCTLW_BRF_OFS) |
EUSCI_A_MCTLW_OS16;
EUSCI_A0->CTLW0 &= ~EUSCI_A_CTLW0_SWRST; // Initialize eUSCI
// EUSCI_A0->IFG &= ~EUSCI_A_IFG_RXIFG; // Clear eUSCI RX interrupt flag
// EUSCI_A0->IE |= EUSCI_A_IE_RXIE; // Enable USCI_A0 RX interrupt
// Enable global interrupt
// P1->IE |= 0x02;
//NVIC->ISER[1]=1;
__enable_irq();
// Enable ADC interrupt in NVIC module
NVIC->ISER[0] = 1 << ((ADC14_IRQn) & 31);
// *Ensures SLEEPONEXIT takes effect immediately
__DSB();
// __delay_cycles(1500000);
while (1)
{
// for (i = 20000; i > 0; i--); // Delay
// Start sampling/conversion
ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC;
while (!ADC14->IFGR0);
// data = ADC14->MEM[0];
__sleep();
//
__no_operation(); // For debugger
}
}
// UART interrupt service routine
void ADC14_IRQHandler(void)
{
volatile unsigned int data ;
data = ADC14->MEM[0];
while(!(EUSCI_A0->IFG & EUSCI_A_IFG_TXIFG));
// Echo the received character back
EUSCI_A0->TXBUF = data;
}