Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > microcontroller bootloader in C

Reply
Thread Tools

microcontroller bootloader in C

 
 
Thomas Baier
Guest
Posts: n/a
 
      08-16-2004
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*|*CSTOPB*|*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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-16-2004
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
 
Reply With Quote
 
 
 
 
Thomas Baier
Guest
Posts: n/a
 
      08-16-2004

> 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?
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      08-16-2004
Thomas Baier <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch Bootloader vs bootflash: ciscortp@hotmail.com Cisco 1 06-13-2006 08:05 AM
GRUB Bootloader!! Joe Computer Support 10 10-21-2005 01:32 PM
How to remove unwanted bootloader? Jeff G Computer Support 4 04-16-2005 08:43 AM
Windows 2000 bootloader elaich Computer Support 4 03-04-2005 04:57 PM
Where's the bootloader Use.Netuser.de Computer Support 4 10-03-2004 12:54 PM



Advertisments