Hardware serial ATtiny167 overflows sending or receiving 16 characters


hello everybody!
before asking here, searched in google , in forum , didn't find useful answer.
i using microcontroller attiny167, compile software use arduino 1.0.3 , program use avrisp mkii.
i want use hardware serial communicate terminal. working baudrate of 9600.
the code, write in bottom, works if send or receive less 16 characters. if message larger, not know if has overflow buffer or stackoverflow, microcontroller crash , can make works time disconnecting power supply or flashing again.
i want able write example next sentence: "press start button:"

to sure using hardwareserial libraries, checked in library "arduino.h" has next line:
code: [select]
#define use_software_serial 0

in "hardwareserial.cpp"  can see serial_buffer_size. 16 because ramend 766.
the ramend calculated as:
code: [select]
#define ramstart     (0x100)
#define ramsize      (0x1ff)
#define ramend       (ramstart + ramsize - 1)


i understand here size of buffer delimited. try put serial_buffer_size 8 , still have same behaviour value 16. same hapens if write 32. notice when change value of serial_buffer_size,  save change, compile , reflash!

in next code, check problem in transmision, have same problem in reception. not able receive more 16 characters. if want receive message of 17 characters, crashes , have reset.
so, code works if receive '1', '2', '3' crashes if receive '4' or '5'.
note: know better use switch case instead if , else if, doubt problem...

code: [select]
#include <arduino.h>

#define transmit_speed   9600

void setup( )
{
    serial.begin( transmit_speed );
    serial.print( "\n" );               //flush
    serial.print( "p: " );
}

void loop( )
{
    char key = '\0';
    if ( serial.available( ) )
    { 
        key = serial.read( );
        if( key == '1' )
        {
            serial.print( "_08_4567" );
        }
        else if( key == '2' )
        {
            serial.print( "_15_12345678901" );
        }
        else if( key == '3' )
        {
            serial.print( "_16_abcdefgh1234" );
        }
        else if( key == '4' )
        {
            serial.print( "_17_4567890123456" );
        }
        else if( key == '5' )
        {
            serial.print( "_24_defgh12345678ijklmno" );
        }
        else
        {
            //do nothing
        }
    }     
}


any appreciated. thanks!



Arduino Forum > Using Arduino > Interfacing w/ Software on the Computer > Hardware serial ATtiny167 overflows sending or receiving 16 characters


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support