Tool/software: Code Composer Studio
Hello,
By running the “Example_F28379D_LaunchPadDemo” example, the SCI baud rate is 115200:
void scia_init() { // // Note: Clocks were turned on to the SCIA peripheral // in the InitSysCtrl() function // // // 1 stop bit, No loopback, No parity,8 char bits, async mode, // idle-line protocol // SciaRegs.SCICCR.all =0x0007; // // enable TX, RX, internal SCICLK, Disable RX ERR, SLEEP, TXWAKE // SciaRegs.SCICTL1.all =0x0003; SciaRegs.SCICTL2.bit.TXINTENA =1; SciaRegs.SCICTL2.bit.RXBKINTENA =1; // // 115200 baud @LSPCLK = 22.5MHz (90 MHz SYSCLK) // SciaRegs.SCIHBAUD.all =0x0000; SciaRegs.SCILBAUD.all =53; SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset return; }
But with the integration of this program and the “2837x_rfft_adc_rt” example, the data transmission rate is 57,600. Why? How can I increase the baud rate?
main.c
#include "fpu_rfft.h" // Main include file #include "math.h" #include "examples_setup.h" #include "sci_io.h" //! //! \addtogroup RFFT_EXAMPLES Real FFT of the ADC Input (Real-Time) // @{ //***************************************************************************** // defines //***************************************************************************** #define RFFT_STAGES 9 #define RFFT_SIZE (1 << RFFT_STAGES) #define F_PER_SAMPLE (ADC_SAMPLING_FREQ/(float)RFFT_SIZE) #define USE_TEST_INPUT 1 // If not in test mode, be sure to exclude signal.asm // from the build #define EPSILON 0.1 //***************************************************************************** // globals //***************************************************************************** #ifdef __cplusplus #pragma DATA_SECTION("RFFTdata1") #else #pragma DATA_SECTION(RFFTin1Buff,"RFFTdata1") #endif //__cplusplus uint16_t RFFTin1Buff[2*RFFT_SIZE]; #ifdef __cplusplus #pragma DATA_SECTION("RFFTdata2") #else #pragma DATA_SECTION(RFFTmagBuff,"RFFTdata2") #endif //__cplusplus //! \brief Magnitude Calculation Buffer //! float RFFTmagBuff[RFFT_SIZE/2+1]; #ifdef __cplusplus #pragma DATA_SECTION("RFFTdata2") #else #pragma DATA_SECTION(RFFTmagBuff,"RFFTdata2") #endif //__cplusplus //! \brief Phase Calculation Buffer //! float RFFTphaseBuff[RFFT_SIZE/2]; #ifdef __cplusplus #pragma DATA_SECTION("RFFTdata3") #else #pragma DATA_SECTION(RFFToutBuff,"RFFTdata3") #endif //__cplusplus //! \brief FFT Calculation Buffer //! \note If the number of FFT stages is even, the result of the FFT will //! be written to this buffer //! float RFFToutBuff[RFFT_SIZE]; #ifdef __cplusplus #pragma DATA_SECTION("RFFTdata4") #else #pragma DATA_SECTION(RFFTF32Coef,"RFFTdata4") #endif //__cplusplus //! \brief Twiddle Factors //! float RFFTF32Coef[RFFT_SIZE]; //! \brief RFFT_ADC_F32_STRUCT object //! RFFT_ADC_F32_STRUCT rfft_adc; //! \brief Handle to the RFFT_ADC_F32_STRUCT object //! RFFT_ADC_F32_STRUCT_Handle hnd_rfft_adc = &rfft_adc; //! \brief RFFT_F32_STRUCT object //! RFFT_F32_STRUCT rfft; //! \brief Handle to the RFFT_F32_STRUCT object //! RFFT_F32_STRUCT_Handle hnd_rfft = &rfft; //! \brief Flag to signal the ADC has finished sampling, and storing, //! N points in the FFT input buffer //! volatile uint16_t flagInputReady = 0; //! \brief Index into the FFT input buffer //! volatile uint16_t sampleIndex = 0; //***************************************************************************** // Function Prototypes //***************************************************************************** __interrupt void adcaIsr(); /////////////////////////////////////////////SCI/////////////////////////////////~ void scia_init(void); void scia_fifo_init(void); void scia_xmit(int a); void scia_msg(char *msg); /////////////////////////////////////////////////////////////////////////////////~ int16_t main(void) { // Locals float freq = 0.0; uint16_t i, j; char *msg;//<------sci #ifdef FLASH EALLOW; Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0; memcpy((uint32_t *)&RamfuncsRunStart, (uint32_t *)&RamfuncsLoadStart, (uint32_t)&RamfuncsLoadSize ); FPU_initFlash(); #endif //FLASH FPU_initSystemClocks(); FPU_initEpie(); // Setup ADC-A FPU_initADCA(); //Setup EPWM1A as the sampling clock, EPWM2A as the signal to be //sampled FPU_initEPWM(); //////////////////////////////////////////SCI/////////////////////////////////////~ InitGpio(); // // For this example, only init the pins for the SCI-A port. // GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits // GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS // These functions are found in the F2837xD_Gpio.c file. // EALLOW; GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 3; GpioCtrlRegs.GPBMUX1.bit.GPIO43 = 3; GpioCtrlRegs.GPBGMUX1.bit.GPIO42 = 3; GpioCtrlRegs.GPBGMUX1.bit.GPIO43 = 3; EDIS; // // Step 3. Clear all __interrupts and initialize PIE vector table: // Disable CPU __interrupts // // DINT; // // Initialize PIE control registers to their default state. // The default state is all PIE __interrupts disabled and flags // are cleared. // This function is found in the F2837xD_PieCtrl.c file. // // InitPieCtrl(); // // Disable CPU __interrupts and clear all CPU __interrupt flags: // // IER = 0x0000; // IFR = 0x0000; // // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the __interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in F2837xD_DefaultIsr.c. // This function is found in F2837xD_PieVect.c. // // InitPieVectTable(); scia_init(); scia_fifo_init(); // Initialize the SCI FIFO ///////////////////////////////////////////////////////////////////////////////////~ //Map ISR functions EALLOW; PieVectTable.ADCA1_INT = &adcaIsr; //function for ADCA interrupt 1 EDIS; //Enable global Interrupts and higher priority real-time debug events: PieCtrlRegs.PIEIER1.bit.INTx1 = 1; //Enable ADC1INT IER |= M_INT1; //Enable group 1 interrupts EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM //Start up the EPWMs FPU_startEPWM(); //Link the RFFT_ADC_F32_STRUCT to RFFT_F32_STRUCT. Tail pointer //of RFFT_ADC_F32_STRUCT is passed to the OutBuf pointer of //RFFT_F32_STRUCT hnd_rfft_adc->Tail = &(hnd_rfft->OutBuf); hnd_rfft->FFTSize = RFFT_SIZE; //FFT size hnd_rfft->FFTStages = RFFT_STAGES; //FFT stages hnd_rfft_adc->InBuf = &RFFTin1Buff[0]; //Input buffer (12-bit ADC input) hnd_rfft->OutBuf = &RFFToutBuff[0]; //Output buffer hnd_rfft->CosSinBuf = &RFFTF32Coef[0]; //Twiddle factor hnd_rfft->MagBuf = &RFFTmagBuff[0]; //Magnitude output buffer hnd_rfft->PhaseBuf = &RFFTphaseBuff[0]; //Phase output buffer RFFT_f32_sincostable(hnd_rfft); //Calculate twiddle factor for (i=0; i < RFFT_SIZE; i++){ RFFToutBuff[i] = 0; //Clean up output buffer } for (i=0; i <= RFFT_SIZE/2; i++){ RFFTmagBuff[i] = 0; //Clean up magnitude buffer } for (i=0; i < RFFT_SIZE/2; i++){ RFFTphaseBuff[i] = 0; //Clean up phase buffer } while(1){ msg = "\r\n\n\nHello World!\0"; scia_msg(msg); while(flagInputReady == 0){}; // Wait on ADC ISR to set the flag // before proceeding RFFT_adc_f32(hnd_rfft_adc); // Calculate real FFT (12-bit ADC input) flagInputReady = 0; // Reset the flag #ifdef __TMS320C28XX_TMU__ //defined when --tmu_support=tmu0 in the project // properties RFFT_f32_mag_TMU0(hnd_rfft); //Calculate magnitude RFFT_f32_phase_TMU0(hnd_rfft); //Calculate phase #else RFFT_f32_mag(hnd_rfft); //Calculate magnitude RFFT_f32_phase(hnd_rfft); //Calculate phase #endif //__TMS320C28XX_TMU__ //Find out the maximum frequency component of signal frequency //component signal. This algorithm is only used for finding frequency //of one component frequency signal; in this example it gives the //fundamental frequency of the sampled square wave j = 1; freq = RFFTmagBuff[1]; for(i=2;i<RFFT_SIZE/2+1;i++){ //Looking for the maximum component of frequency spectrum if(RFFTmagBuff[i] > freq){ j = i; freq = RFFTmagBuff[i]; } } //Converting normalized digital frequency to real analog frequency //f = m * fs/N // where m is the bin with the maximum value, fs the sampling // frequency and N the number of points in the FFT freq = F_PER_SAMPLE * (float)j; // Execution never reaches this point return 1; } // End of main //! \brief ADC Interrupt Service Routine //! The ISR will store each sampled value in the FFT buffer, and //! raise the flag once the buffer is full //! __interrupt void adcaIsr() { RFFTin1Buff[sampleIndex++] = AdcaResultRegs.ADCRESULT0; //sampleIndex++ for single channel if(sampleIndex == (RFFT_SIZE - 1) ){ sampleIndex = 0; flagInputReady = 1; } AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; } // @} //addtogroup // End of file ///////////////////////////////////////////////sci////////////////////////////////////////////~ // // scia_xmit - Transmit a character from the SCI // void scia_xmit(int a) { while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {} SciaRegs.SCITXBUF.all =a; } // // scia_msg - Transmit message via SCIA // void scia_msg(char * msg) { int i; i = 0; while(msg[i] != '\0') { scia_xmit(msg[i]); i++; } } // // scia_fifo_init - Initialize the SCI FIFO // void scia_fifo_init() { SciaRegs.SCIFFTX.all = 0xE040; SciaRegs.SCIFFRX.all = 0x2044; SciaRegs.SCIFFCT.all = 0x0; } // // scia_init - SCIA 8-bit word, baud rate 0x000F, default, 1 STOP bit, // no parity // void scia_init() { // // Note: Clocks were turned on to the SCIA peripheral // in the InitSysCtrl() function // // // 1 stop bit, No loopback, No parity,8 char bits, async mode, // idle-line protocol // SciaRegs.SCICCR.all =0x0007; // // enable TX, RX, internal SCICLK, Disable RX ERR, SLEEP, TXWAKE // SciaRegs.SCICTL1.all =0x0003; SciaRegs.SCICTL2.bit.TXINTENA =1; SciaRegs.SCICTL2.bit.RXBKINTENA =1; // // 115200 baud @LSPCLK = 22.5MHz (90 MHz SYSCLK) // SciaRegs.SCIHBAUD.all =0x0000; SciaRegs.SCILBAUD.all =53; SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset return; } ///////////////////////////////////////////////////////////////////////////////////////////~
Thanks for your help.
Regards,
Amin