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.

How to split a transmitted data to receive full data.



Hi,

I am using Delfino F28335. I am using ADC in sync with SCI. When ADC pin is low, the value is around 5, and I see that being transmitted and received as 5. However, when ADC pin value is high at 4095, I see that SCIA transmit is 4095. However, the SCIA receive is 255. I am receiving the last 8 bits back but not the front 8 bits to receive 4095 back. Is there a way to have the program read the first 8 bits, shift them out and then read the last 8 bits and augment them together to get 4095.

Thanks.

  • do this:
    adc_value_h=value>>8;
    adc_value_l=value&0xFF;
    Gastón
  • Hi Gaston,

    I think I have written the question wrong. I am sending 2 bytes out. However, I receive just 1 byte. How do I get the answer to be 2 bytes long. The SCIRXBUF can only read 8 bits. The relevant piece of code is as follows:

    __interrupt void sciaTxFifoIsr(void)

    {

    Uint16 i;

    Uint16 j;

    for(i=0; i< 8; i++)

    {

    SciaRegs.SCITXBUF=sdataA[i]; // Send data

    }

    for(i=0; i< 8; i++){

    for (j=0; j<48; j = j+2){ //Increment send data for next cycle

    sdataA[i] = AdcBuf[j];

    }

    }

    SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear SCI Interrupt flag

    PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK

    }

    __interrupt void sciaRxFifoIsr(void)

    {

    Uint16 i;

    for(i=0; i<8; i++) {

    rdataA[i]=SciaRegs.SCIRXBUF.all; // Read data

    }

    SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag

    SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag

    PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack

    }

    So my sdata[i] = 4095, however, rdata[i] = 255. How do I get rdata[i] to be 4095 too. I hope that clears up my problem. Also, my sdata[i] can be anything from 0 to 4095.

    Thanks.

    Waqqas 

  • usually the SCITXBUF is 1 bytes long. looking your code, let me ask you something:
    1) How do you kow when the SCITXBUF is ready to receive another character?
    Did you read the Sci.pdf of your device?
    in this link you'll find examples code www.ti.com/.../controlsuite
    regards
    Gastón
  • Hi Gaston,
    I am using the Loopback_interrupt example as a base code and including some extra lines from my side. I am assuming the fifo interrupts later in the code show that the SCITXBUF is ready for receiving another character.
    Also, because, when I toggle the values from 0 to 10 into SCIB, I can see that the SCITXBUF and SCIRXBUF changing values based on different values in sdataB.
    If SCITXBUF is 8 bits long, then is there a way for me to get a value from 0 to 4095 into it and be able to read that on SCIRXBUF in SCIA?

    Thanks.
    Waqqas
  • maybe you should try sending a simple character first and read the pdf to understand how the things works. How many bytes has sdataA? the i variable goes from 0 to 8? why? How many bytes has AdcBuf?
    regards
    Gastón
  • Hi Gaston,
    I am reading up on the pdf once more. sdataA has 2 bytes, and the i variable goes from 0 to 8 for no particular reason. Just seeing how the numbers are coming in. AdcBuf has also 2 bytes.
    As you said, I looked SCITXBUF and it is also 1 byte.
    Is there a way to get 2 bytes in these registers to get the answer that I want.

    Thanks.

    Waqqas
  • if sdataA has 2 bytes, then why i goes from 0 to 8? wouldn't be 0 to 1? When you send a byte from the TX buffer, you have to wait until the buffer is ready to accept another byte.

    for(i=0; i< 1; i++)

    {

    SciaRegs.SCITXBUF=sdataA[i]; // Send data
    TX BUFFER EMPTY?--->>when this happens TX buffer will accept another byte

    }

    if you want to get to bytes, then do this:

    adc_value_h=value>>8;
    adc_value_l=value&0xFF;

    you send this values to PC?
    if adcBuf has 2 bytes, why j goes from 0 to 48?
    Maybe you should first do some reading and check some example code to understand how this thing works.

    Gastón