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/TMS320F28379D: scia problem

Part Number: TMS320F28379D


Tool/software: Code Composer Studio

with this code i sent to scia pins the numbers in the vector:[1,2,3,4,5] in cycle. if i use pins 43 44  i see the result on the serial monitor. when i try to change the pins using 28 29, something goes wrong.... i have to transmit these numbers to an arduino (but the launchpad has to stay linked to the pc with the usb  cable, for this i cant use pins 43 44). why i doesn't read nothing with arduino seriial monitor using the others pins.? im pretty sure that the error is in my pins configuration. someone can tell me where is,the error in my code, please?

thanks for the help

#include <math.h>
#include "F28x_Project.h"
#include <stdio.h>
Uint16 LoopCount=0;
Uint16 Received[100];
int vettore[5]={1,2,3,4,5};
Uint16 n=4;
int x=0;
Uint16 ReceivedChar;
Uint16 i=0;
int prova=1;
int fine=100;
float f=2.43;
float *f_ptr=&f;

float nx = 3.567;

void scia_echoback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void scia_msg(char *msg);

void scia_rec (void);
void scia_float(int *f);
void ftoa(float n, char* res, int afterpoint);
void main(void)

{ InitSysPll(XTAL_OSC, IMULT_20, FMULT_0, PLLCLK_BY_2);
char *msg;

InitSysCtrl();
InitGpio();

//GPIO_SetupPinMux(43, GPIO_MUX_CPU1, 0x0F);
//GPIO_SetupPinOptions(43, GPIO_INPUT, GPIO_PUSHPULL);
//GPIO_SetupPinMux(42, GPIO_MUX_CPU1, 0x0F);
//GPIO_SetupPinOptions(42, GPIO_OUTPUT, GPIO_ASYNC);
GPIO_SetupPinMux (29 , GPIO_MUX_CPU1 , 2 ); // set pin 18 to MUX position 2 as UARTA RX
GPIO_SetupPinOptions(29 , GPIO_INPUT , GPIO_PUSHPULL); // set pin as RX
GPIO_SetupPinMux (28 , GPIO_MUX_CPU1 , 2 ); // set pin 19 to MUX position 2 as UARTA TX
GPIO_SetupPinOptions(28 , GPIO_OUTPUT , GPIO_ASYNC );
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();


scia_fifo_init(); // Initialize the SCI FIFO
scia_echoback_init(); // Initialize SCI for echoback

__byte(&fine,1) = fine + '0';
for(LoopCount=0;LoopCount<1000;LoopCount++) {

for(i=0;n>=i;i++)
{
__byte(&prova,0) = vettore[i]+ '0';

SciaRegs.SCITXBUF.all =prova;

}
i=0;
//if (i=n){SciaRegs.SCITXBUF.all =fine; }
DELAY_US(500000);


}
}


void scia_rec (void)
{
while(SciaRegs.SCIFFRX.bit.RXFFST == 0) { } // wait for empty state
Received[x] = SciaRegs.SCIRXBUF.all;
x++;
}
void scia_echoback_init()
{

SciaRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
SciaRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
SciaRegs.SCICTL2.all = 0x0003;
SciaRegs.SCICTL2.bit.TXINTENA = 1;
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
SciaRegs.SCIHBAUD.all = 0x0002;
SciaRegs.SCILBAUD.all = 0x008B;

SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset


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.all = 0x0003; //enable TX,RX interrupt
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCICTL2.bit.RXBKINTENA = 1;

ScibRegs.SCIHBAUD.all = 0x0002;
ScibRegs.SCILBAUD.all = 0x008B;
ScibRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}

void scia_xmit(int a)
{
while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
SciaRegs.SCITXBUF.all =a;

while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
ScibRegs.SCITXBUF.all =a;

}
void scia_msg(char * msg)
{
int i;
i = 0;
while(msg[i]!='\0')
{scia_xmit(msg[i]); i++;}}
void scia_float(int *f)
{
int i;
i = 0;
while(f[i]!='\0')
{scia_xmit(f[i]); i++;}}


void scib_fifo_init(void)
{
ScibRegs.SCICCR.all = 0x0007;
ScibRegs.SCICTL1.all = 0x0003;
ScibRegs.SCIHBAUD.all = 0x0000;

ScibRegs.SCIFFTX.all = 0xE040;

ScibRegs.SCIFFRX.bit.RXFFINTCLR =1;
ScibRegs.SCIFFRX.bit.RXFIFORESET = 1;
}

void scia_fifo_init()
{
SciaRegs.SCIFFTX.all = 0xE040;
SciaRegs.SCIFFRX.all = 0x2044;
SciaRegs.SCIFFCT.all = 0x0;}

  • hi ,

    Please check the GPIO muxingTable 8-7. GPIO Muxed Pins of the TRM .

    If you see here the mux expectation for the GPIO28 and 29 ti get mux as SCIRXA and TXA are 0x1 which was 0xF for 42/43.

    Similarly , the GPIO direction should be changed to map to the right TX(o/p)  and RX (i/p).

    The correct configuration are :

    GPIO_SetupPinMux (29 , GPIO_MUX_CPU1 , 1 ); 
    GPIO_SetupPinOptions(29 , GPIO_OUTPUT , GPIO_ASYNC); 
    GPIO_SetupPinMux (28 , GPIO_MUX_CPU1 , 1 ); 
    GPIO_SetupPinOptions(28 , GPIO_INPUT ,  GPIO_PUSHPULL);

    Regards.

  • thanks for the help, i have try to change my code but i dont sen any change on my pins 28 29 exit :(

    if you try the code you can see that using pin 42 43 you have the true exit (on the serial monitor) but using the others 2 pins instead, you dont have any exit(looking with an arduino)...

    i dont understand where is the problem....

    #include <math.h>
    #include "F28x_Project.h"
    #include <stdio.h>
    Uint16 LoopCount=0;
    Uint16 Received[100];
    int vettore[5]={1,2,3,4,5};
    Uint16 n=4;
    int x=0;
    Uint16 ReceivedChar;
    Uint16 i=0;
    int prova=1;
    int fine=100;
    float f=2.43;
    float *f_ptr=&f;

    float nx = 3.567;

    void scia_echoback_init(void);
    void scia_fifo_init(void);
    void scia_xmit(int a);
    void scia_msg(char *msg);

    void scia_rec (void);
    void scia_float(int *f);
    void ftoa(float n, char* res, int afterpoint);
    void main(void)

    { InitSysPll(XTAL_OSC, IMULT_20, FMULT_0, PLLCLK_BY_2);
    char *msg;

    InitSysCtrl();
    InitGpio();

    //GPIO_SetupPinMux(43, GPIO_MUX_CPU1, 0x0F);
    //GPIO_SetupPinOptions(43, GPIO_INPUT, GPIO_PUSHPULL);
    //GPIO_SetupPinMux(42, GPIO_MUX_CPU1, 0x0F);
    //GPIO_SetupPinOptions(42, GPIO_OUTPUT, GPIO_ASYNC);
    GPIO_SetupPinMux (29 , GPIO_MUX_CPU1 , 1 );
    GPIO_SetupPinOptions(29 , GPIO_OUTPUT , GPIO_ASYNC);
    GPIO_SetupPinMux (28 , GPIO_MUX_CPU1 , 1 );
    GPIO_SetupPinOptions(28 , GPIO_INPUT , GPIO_PUSHPULL);
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();


    scia_fifo_init(); // Initialize the SCI FIFO
    scia_echoback_init(); // Initialize SCI for echoback

    __byte(&fine,1) = fine + '0';
    for(LoopCount=0;LoopCount<1000;LoopCount++) {

    for(i=0;n>=i;i++)
    {
    __byte(&prova,0) = vettore[i]+ '0';

    SciaRegs.SCITXBUF.all =prova;

    }
    i=0;
    //if (i=n){SciaRegs.SCITXBUF.all =fine; }
    DELAY_US(500000);


    }
    }


    void scia_rec (void)
    {
    while(SciaRegs.SCIFFRX.bit.RXFFST == 0) { } // wait for empty state
    Received[x] = SciaRegs.SCIRXBUF.all;
    x++;
    }
    void scia_echoback_init()
    {

    SciaRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
    SciaRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
    SciaRegs.SCICTL2.all = 0x0003;
    SciaRegs.SCICTL2.bit.TXINTENA = 1;
    SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
    SciaRegs.SCIHBAUD.all = 0x0002;
    SciaRegs.SCILBAUD.all = 0x008B;

    SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset


    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.all = 0x0003; //enable TX,RX interrupt
    ScibRegs.SCICTL2.bit.TXINTENA = 1;
    ScibRegs.SCICTL2.bit.RXBKINTENA = 1;

    ScibRegs.SCIHBAUD.all = 0x0002;
    ScibRegs.SCILBAUD.all = 0x008B;
    ScibRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
    }

    void scia_xmit(int a)
    {
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    SciaRegs.SCITXBUF.all =a;

    while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
    ScibRegs.SCITXBUF.all =a;

    }
    void scia_msg(char * msg)
    {
    int i;
    i = 0;
    while(msg[i]!='\0')
    {scia_xmit(msg[i]); i++;}}
    void scia_float(int *f)
    {
    int i;
    i = 0;
    while(f[i]!='\0')
    {scia_xmit(f[i]); i++;}}


    void scib_fifo_init(void)
    {
    ScibRegs.SCICCR.all = 0x0007;
    ScibRegs.SCICTL1.all = 0x0003;
    ScibRegs.SCIHBAUD.all = 0x0000;

    ScibRegs.SCIFFTX.all = 0xE040;

    ScibRegs.SCIFFRX.bit.RXFFINTCLR =1;
    ScibRegs.SCIFFRX.bit.RXFIFORESET = 1;
    }

    void scia_fifo_init()
    {
    SciaRegs.SCIFFTX.all = 0xE040;
    SciaRegs.SCIFFRX.all = 0x2044;
    SciaRegs.SCIFFCT.all = 0x0;}

  • hi ,

    How are you connecting these pins to the serial monitor ? is it using an RS232 cable or something ?

    Regards.

  • I'm using the standard usb cable, i have problem when i change the pins configuration...

    I need to use other 2 pins like 28 29 but my code dont work:(

    I dont find any example code with scia pins different from 42 43...can you help me?

    Thanks :)

  • hi,

    leonardo luchetti said:
    I dont find any example code with scia pins different from 42 43...can you help me?

    That's because the launchpad board has the FTDI and circuitry to connect only these 2 GPIO pins to the usual USB cable .

    leonardo luchetti said:
    I need to use other 2 pins like 28 29

    If this is needed you would need to use some external cable connections like the RS232 cable or a USB to UART converter cable and map it to the GPIO that you want to use.

    Regards.

  • Hi meghana thanks help me, i need onli 2 pins to transimt and read differerents from 42-43 to comunicate wih an arduino

    I have try many example also with scib but i dont find one that work

    I m only looking to send a simple "hello word" to an arduino and receive a echoback but its hardest then prevision...in 2 month i dont transmit nothing

    I use just 42 43 to comunicate with pc but i need use other 2 pins... thank for help

  • hi ,

    As i said you can use other pins but would need a separate connector.

    Have you tried that ?

    MEGHANA MANAVAZHI said:
    If this is needed you would need to use some external cable connections like the RS232 cable or a USB to UART converter cable and map it to the GPIO that you want to use.

    Regards.

  • No i have tried with 2 normal electric wire but with many configuration and nothing is change...no comunication between these..

  • ok please use the connectors as suggested.