This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Not storing the data from SBUF

Hi MCU is recieving the data from other MCU& i am unable to store the data using SBUF..so pls help me.. only the last byte is receiving again & again...

thanks

here my source code

p = 0; for(i1=0;i1<448;i1++) ser_buf[i1]=SBUF;

for(i2=0;i2<8;i2++) { for(i1=0;i1<48;i1++) prt_buf[i1] = 0; for(i1 = 0;i1<48;i1++) prt_buf[i1] =ser_buf[p++];

print_graph();

}

Parents
  • Hello,

    do not strictly concentrate on the code, be focus on what you want.
    I guess you want transmit a fixed number of bytes between two device.
    Every time one byte is received the RI flag is raised, and if enabled the serial interrupt too.

    You shall enable the global interrupt and serial interrupt only once in the beginning of your program.
    When your buffer is full you step over index 0, so this byte does not change the byte since first time filled.
    You could also use the idea from mahitama charak, but be sure that you understand you did.

    btw: Please place source code source code between pre-tags.

    Greetings,

    David

Reply
  • Hello,

    do not strictly concentrate on the code, be focus on what you want.
    I guess you want transmit a fixed number of bytes between two device.
    Every time one byte is received the RI flag is raised, and if enabled the serial interrupt too.

    You shall enable the global interrupt and serial interrupt only once in the beginning of your program.
    When your buffer is full you step over index 0, so this byte does not change the byte since first time filled.
    You could also use the idea from mahitama charak, but be sure that you understand you did.

    btw: Please place source code source code between pre-tags.

    Greetings,

    David

Children