[ECOS] EB40A (AT91) serial port oddness

Tom Lynn tom.lynn@hypertag.com
Thu Sep 30 06:53:00 GMT 2004


I'm getting some weird behaviour on an EB40A (AT91) serial port.
With the code below, which just tries to emit the 65 byte string
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=\n",
I'm reading bytes such as:

...
'UVWXYZabcdefghij'
'klmnopqrstuvwxyz'
'0123456789-=\nBCD'
'EFGHIJKLMNOPQRST'
'UVWXYZabcdefghij'
'klmnopqrstuvwxyz'
'0123456789-=\n\t\r\x11'
'\x15\x19\x1d!%)-159=AEIMQ'
'UY]aei\x85\x89\x8d\x91\x95\x99\x9d\xa1\xa5\xa9'
'\xad\xb1\xb5\xb9\xbd\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1\xe5\xe9'
'\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1\xe5\xb5\xf5)\xff\t\r'
'\x11\x15\x19\x1d!%)-159=AEIM'
'QUY]aei\x85\x89\x8d\x91\x95\x99\x9d\xa1\xa5'
'\xa9\xad\xb1\xb5\xb9\xbd\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1\xe5'
'\xe9\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1\xe5\xb5\xf5)\xff\t'
'\r\x11\x15\x19\x1d!%)-159=AEI'
'MQUY]aei\x85\x89\x8d\x91\x95\x99\x9d\xa1'
'\xa5\xa9\xad\xb1\xb5\xb9\xbd\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1'
'\xe5\xe9\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1\xe5\xb5\xf5)\xff'
'BCDEFGHIJKLMNOPQ'
'RSTUVWXYZabcdefg'
'hijklmnopqrstuvw'
'xyz0123456789-=\n'
'\t\r\x11\x15\x19\x1d!%)-159=AE'
'IMQUY]aei\x85\x89\x8d\x91\x95\x99\x9d'
'\xa1\xa5\xa9\xad\xb1\xb5\xb9\xbd\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd'
'\xe1\xe5\xe9\xc1\xc5\xc9\xcd\xd1\xd5\xd9\xdd\xe1\xe5\xb5\xf5)'
'\xffBCDEFGHIJKLMNOP'
'QRSTUVWXYZabcdef'
...

The AEIMQUY suggests jumps of 4, and the intermittent almost-
correct output (the 'A' is always missing) together make me think
that it's the debugging connection (running at 38400, i.e. 9600*4)
that's causing the problem.  I've played with all the switches I
can find and can't turn the damn thing off though.  Any ideas?

(Email me if you want to look at the config file I'm using.)

Tom

// test_serial.cpp

#include <pkgconf/system.h>
#include <cyg/infra/testcase.h> // test macros
#include <cyg/infra/cyg_ass.h>  // assertion macros
#include <pkgconf/kernel.h>
#include <cyg/kernel/kapi.h>
#include <cyg/io/io.h>
#include <cyg/io/serialio.h> // not to be confused with seraglio, which 
is more fun.
#include <pkgconf/io_serial.h> // yes, there really are io_serial.h and 
serialio.h.
#include <cyg/io/config_keys.h> // magic values for prodding at io functions
#include <cyg/infra/diag.h>     // Defines diag_printf, for diagnostic 
printing.
#include <cyg/hal/hal_arch.h> // for CYGNUM_HAL_STACK_SIZE_TYPICAL

extern "C"
void  serialtest_main()
{
    cyg_io_handle_t  handle;
    cyg_io_lookup( "/dev/ser1", &handle ); // ignoring errors
   
    // Set serial port parameters to 9600-8-N-1
    {
        cyg_serial_info_t  new_cfg;
        unsigned int len = sizeof(new_cfg);
        cyg_io_get_config( handle, CYG_IO_GET_CONFIG_SERIAL_INFO,
                           &new_cfg, &len );

        new_cfg.baud        = CYGNUM_SERIAL_BAUD_9600;
        new_cfg.word_length = CYGNUM_SERIAL_WORD_LENGTH_8;
        new_cfg.stop        = CYGNUM_SERIAL_STOP_1;
        new_cfg.parity      = CYGNUM_SERIAL_PARITY_NONE;
        new_cfg.flags       = CYGNUM_SERIAL_FLOW_NONE;
   
        cyg_io_set_config( handle, CYG_IO_SET_CONFIG_SERIAL_INFO,
                           &new_cfg, &len );
        cyg_thread_delay(10);
    }
   
    while( 1 )
    {
        const unsigned char testdata[] = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=\n";
        unsigned int sz = 65;
        cyg_io_write( handle, testdata, &sz );
        cyg_thread_delay(10);
    }
}


// --- entrypoint boilerplate from here ---

static  unsigned char  stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
static  cyg_thread     thread_data;
static  cyg_handle_t   thread_handle;

extern "C"
void cyg_start()
{
    cyg_thread_create( 10, (cyg_thread_entry_t*)serialtest_main,
        0, "serialtest", &stack[0], CYGNUM_HAL_STACK_SIZE_TYPICAL,
        &thread_handle, &thread_data );
    cyg_thread_resume(thread_handle);
    cyg_scheduler_start();
}

-- 
Tom Lynn, Software Engineer, Hypertag Ltd.
William Gates Building, JJ Thomson Avenue, Cambridge CB3 0FD

Tel: 01223 763710   Fax: 08714 335288   Web: www.hypertag.com


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list