By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

microcontroller bootloader in C

P: n/a
Hi there,

I've got a little problem while working on a bootloader for a C164
microcontroller. The microcontroller gets the data over the serial port.
I've already implemented some functions that transmit some vmc and hex
files to the controller while there is a OS running on it. But now I'd like
to transmit my one bootstrap loader and I've got some problems with the
serial communication in C.

Here's my code to configure the serial port under linux (I'm working on Suse
Linux prof. 9.0):

int openport(char* device)
{
********int*fd;
********struct*termios**current;****************//IO-Settings
********struct*termios*options;

********fd*=*open(device,*O_RDWR*|*O_NOCTTY);

********if*(fd*==*-1)
****************return*-1;

********bzero(&options,*sizeof(options));
********tcgetattr(fd,*&options);

********cfsetispeed(&options,*B19200);
********cfsetospeed(&options,*B19200);

********
********options.c_cflag*=*B19200*|*CRTSCTS*|*CSTOP B*|*CLOCAL*|*CREAD;
********//8*databits,*no*paritybit,*1*stopbit
********options.c_cflag*&=*~PARENB;
********options.c_cflag*&=*~CSTOPB;
********options.c_cflag*&=*~CSIZE;
********options.c_cflag*|=*CS8;
********options.c_iflag*=*IGNPAR;
********options.c_oflag*=*0;
********options.c_lflag*=*0;

********tcflush(fd,*TCIFLUSH);
********tcsetattr(fd,*TCSANOW,*&options);

********return*(fd);
}

And now I simply want to transmit a zero byte (say 1 startbit, 8 zero bits
and 1 stopbit):

int comport = openport("/dev/ttyS0");
write(comport,0,1);
usleep(250);
unsigned char cbuf = 0;
while(read(sfd, &cbuf, 1)>0) {
********printf("%i\t",(int)*cbuf);
}
but the microcontroller doesn't answer. It should return an identification
byte, but I do not receive anything at all. I've got some software for
windows that works fine (but only under windows) and I spied on its
communication between itself and the comport and got this as the first two
lines:

#00*************//out***-*zero*byte
#F8#D5**********//in****-*identification*byte

So there can't be a failure at the microcontroller.
Thanks for any help.

Thomas
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Thomas Baier wrote:
I've got a little problem while working on a bootloader for a C164
microcontroller. The microcontroller gets the data over the serial port.
I've already implemented some functions that transmit some vmc and hex
files to the controller while there is a OS running on it. But now I'd like
to transmit my one bootstrap loader and I've got some problems with the
serial communication in C.

[...]


You appear to be lost. This is a C++ newsgroup. comp.lang.c is just
down the corridor, on the left. Keep in mind, though, that hardware
programming is not part of the language, so you can still be off-topic
there.

V
Jul 22 '05 #2

P: n/a
You appear to be lost. This is a C++ newsgroup. comp.lang.c is just
well I know but any answer in C++ or in C would be helpful for me, I'll post
in comp.lang.c too
down the corridor, on the left. Keep in mind, though, that hardware
programming is not part of the language, so you can still be off-topic
there.


yeah, that's right, too, but I didn't find any newsgroup matching my topic.
Can you point me to some, please?
Jul 22 '05 #3

P: n/a
Thomas Baier <th****@tho-bai.de> spoke thus:
well I know but any answer in C++ or in C would be helpful for me, I'll post
in comp.lang.c too
Don't.
yeah, that's right, too, but I didn't find any newsgroup matching my topic.
Can you point me to some, please?


comp.arch.embedded, perhaps.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.