From: Philippe L. <phi...@li...> - 2006-05-05 09:45:58
|
Hello, Le Jeudi 4 Mai 2006 18:00, Jean-Paul a écrit : > Hello, > > Anyway, you are better off with only one serial function. > > You might be "freezed" by your putchar routine. That's effectively happening with the mix between buffered routines and register usage. My previous source file post seems to be a *BAD PRACTISE* example. > > Many putchar() routines begin with > while (!TI)... > > TI is set by hardware AFTER a byte has been sent. > If you don't set TI once after powerup, before calling putchar() the first > time, you'll wait forever... > > You can make it the other way round : > In putchar(): > clear TI, > write SBUF > wait for TI > return Good advice ;)) I followed it and it works now like a charm ! I attach a fully working source code example. So, to get back to best practise, does the following makes sense ? 1. trust ser.h ser_init() routine for serial line initialisation after autobaud(). 2. KISS (keep it stupid simple) : write your own putchar & getchar with direct register use. Thanks a lot for your help. > > Le Jeudi 04 Mai 2006 02:10, Philippe Latu a écrit : > > Hello list, > > > > I'm actually developing labs & docs in french on a MSC1210 board with > > SDCC. > > > http://www.linux-france.org/~platu/embedded/ > > > > I have difficulties with serial interface management. > > > > I searched through google, sdcc user's guide, .h files, etc. > > > > I found 2 different kinds of serial putchar & getchar. > > > > . Use of ser_putc and ser_getc provided through ser.h > > . Use of registers RI, TI, SBUF > > > > What is the best practise between these ? > > > > I didn't find source files using ser_getc. When I tried it, the serial > > line > > > became unusable. > > I attach the example file I'm working on. It's a mixture with ser_putc > > and > > > RI,SBUF which ... almost works. I still have XON/XOFF problems. > > > > Any help would be greatly appreciated ;)) > > -- > > - Philippe Latu > > (GPG|PGP) KeyId 0x742A6424 > > Public Key http://www.linux-france.org/~platu/key.asc > > < G N U / Linux > > > philippe.latu(at)linux-france.org > > Projet inetdoc.Linux > > http://www.linux-france.org/prj/inetdoc > > </> > > < I U T 'A' Paul Sabatier > > > philippe.latu(at)iut-tlse3.fr - 05.62.25.80.28 > > Enseignant/Chargé de mission Systèmes & Réseau > > </> -- - Philippe Latu (GPG|PGP) KeyId 0x742A6424 Public Key http://www.linux-france.org/~platu/key.asc < G N U / Linux > philippe.latu(at)linux-france.org Projet inetdoc.Linux http://www.linux-france.org/prj/inetdoc </> < I U T 'A' Paul Sabatier > philippe.latu(at)iut-tlse3.fr - 05.62.25.80.28 Enseignant/Chargé de mission Systèmes & Réseau </> |