This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28335: How can I connect TMS320F28335 Bluetooth to PC with SCI communication.

Part Number: TMS320F28335

Tool/software: Code Composer Studio

Hi I'm using TMS320F28335 with FB155BC which is bluetooth module.

I confirmed SCI fifo loopback.

//////////////////////////////////////////////////////////////////////////////

//###########################################################################
// Description:
//! \addtogroup f2833x_example_list
//! <h1>Timer based blinking LED (timed_led_blink)</h1>
//!
//! This example configures CPU Timer0 for a 500 msec period, and toggles the GPIO32
//! LED on the 2833x eZdsp once per interrupt. For testing purposes, this example
//! also increments a counter each time the timer asserts an interrupt.
//!
//! \b Watch \b Variables \n
//! - CpuTimer0.InterruptCount
//!
//! \b External \b Connections \n
//! - Monitor the GPIO32 LED blink on (for 500 msec) and off (for 500 msec) on
//! the 2833x eZdsp.
//
//###########################################################################
// $TI Release: F2833x/F2823x Header Files and Peripheral Examples V142 $
// $Release Date: November 1, 2016 $
// $Copyright: Copyright (C) 2007-2016 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################

#include "DSP28x_Project.h" // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
__interrupt void cpu_timer0_isr(void);
__interrupt void scibTxFifoIsr(void);
__interrupt void scibRxFifoIsr(void);
void scib_fifo_init();
void error(void);

// Global variables

unsigned char sdataB[8]; // Send data for SCI-B
unsigned char rdataB[8]; // Received data for SCI-A
Uint16 rdata_pointB; // Used for checking the received data
Uint16 dummy = 0;
Uint16 dummy2 = 0;
Uint32 cnt_Tx = 0;

void main(void)
{
Uint16 i;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initialize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio(); // Skipped for this example
InitScibGpio();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;

// Initialize the 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 DSP2833x_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 DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &cpu_timer0_isr;
PieVectTable.SCIRXINTB = &scibRxFifoIsr;
PieVectTable.SCITXINTB = &scibTxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize the Device Peripheral. This function can be
// found in DSP2833x_CpuTimers.c
InitCpuTimers(); // For this example, only initialize the Cpu Timers
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0 to interrupt every 500 milliseconds:
// 150MHz CPU Freq, 50 millisecond Period (in uSeconds)
ConfigCpuTimer(&CpuTimer0, 150, 500);
#endif
#if (CPU_FRQ_100MHZ)
// Configure CPU-Timer 0 to interrupt every 500 milliseconds:
// 100MHz CPU Freq, 50 millisecond Period (in uSeconds)
ConfigCpuTimer(&CpuTimer0, 100, 500000);
#endif

// To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any
// of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2833x_CpuTimers.h), the
// below settings must also be updated.

CpuTimer0Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0

// Step 5. User specific code, enable interrupts:


// Enable CPU INT1 which is connected to CPU-Timer 0:
IER |= M_INT1;
IER |= M_INT9;

// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER9.bit.INTx3 = 1;
PieCtrlRegs.PIEIER9.bit.INTx4 = 1;

// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

scib_fifo_init();

while(!(ScibRegs.SCICTL2.bit.TXRDY));
for(i = 0; i<8; i++)
{
sdataB[i] = 0;

}

rdata_pointB = sdataB[0];

// Step 6. IDLE loop. Just sit and loop forever (optional):
for(;;)
{
}
}

//////////////////////////////////////////////////////Function////////////////////////////////////////////////////////////
void error(void)
{
__asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}

void scib_fifo_init()
{
ScibRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScibRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScibRegs.SCICTL2.bit.TXINTENA =1;
ScibRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD = 0x0000; //115200(LSPCLK=37.5Mhz) //XA3300
SciaRegs.SCILBAUD = 0x0027;
//ScibRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
ScibRegs.SCIFFTX.all=0xC028;
ScibRegs.SCIFFRX.all=0x0028;
ScibRegs.SCIFFCT.all=0x00;

ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
}


//////////////////////////////////////////////////////Interrupt///////////////////////////////////////////////////////////
__interrupt void cpu_timer0_isr(void)
{
CpuTimer0.InterruptCount++;
cnt_Tx++;

// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

Uint16 jk = 0;
__interrupt void scibTxFifoIsr(void)
{
Uint16 i;
for(i=0; i< 8; i++)
{
ScibRegs.SCITXBUF=sdataB[i]; // Send data
}

for(i=0; i< 8; i++) //Increment send data for next cycle
{
/*
if(i == 0)
sdataB[0] = 'A';
else if(i >= 1 && i <=5)
sdataB[i] = 'A'+i;
else if(i == 6)
sdataB[i] = ']';
else
sdataB[i] = 0x0D;
*/
sdataB[i] = jk++;
if(jk > 50)
{
jk = 0;
}
dummy++;
}

ScibRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear Interrupt flag
PieCtrlRegs.PIEACK.all|=PIEACK_GROUP9; // Issue PIE ACK

}

__interrupt void scibRxFifoIsr(void)
{

Uint16 i;
for(i=0;i<8;i++)
{
rdataB[i]=ScibRegs.SCIRXBUF.all; // Read data
}
rdata_pointB = (rdata_pointB-1) & 0x00FF;

ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
ScibRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
PieCtrlRegs.PIEACK.all|=PIEACK_GROUP9; // Issue PIE ack
dummy2++;
}

//===========================================================================
// No more.
//===========================================================================

Above is my code SCI FIFO to HyperTerminal.

But any texts aren't transmitted

Thank you.

  • Hi Joon Woo,

    Joon Woo Lee said:
    Above is my code SCI FIFO to HyperTerminal.

    I didn't see any concerns with the way your SCI module is configured. Have you tried a more precise value for SCILBAUD? According to the following formula,

    BRR = LSPCLK / (SCI Asynchronous Baud * 8) - 1 

    BRR = (37.5MHz) / (115200 * 8) -1 = 40.69

    Have you checked what the actual baud rate is by using an oscilloscope? Have you probed the TX/RX pins to check if the data is transmitting or there is data being received? 

    Best Regards,

    Marlyn