Skip to content

Speeding Up the Bootloader

March 12, 2014

When I moved to the consolidated olduino/shield adapter, I re-coded the program in the AVR to use the MISR 74595 to load the 1802’s programs. I didn’t notice at first but the uploading was starting to be really slow for large programs. I did a snapshot with the logic analyzer and saw an 11K byte program taking 7-8 seconds to load.

14-03-10 loading 11252
You can see each of the 256 byte pages being loaded as bursts on miso and sck interspersed with much shorter quiet spots where the data is coming from the PC. Since the PC transmission is only 57600 baud, the 1802 load is ridiculously slow.

I had done the busout routine to load the shift register in the simplest possible way using digitalWrite which is always slow.

void busout(uint8_t t){ //put a byte on the bus
  pinMode(MISO,OUTPUT);  //we begin to drive MISO
  for (int i=0;i<8;i++){
      digitalWrite(MISO, t&0x80);

I replaced the guts of the routine with SBI/CBI instructions to set and clear the register bits the quickest way I know how.

  for (int i=0;i<8;i++){
      if(MISO, t&0x80){
      sbi(PORTB,5);cbi(PORTD,7); //clkpin up, notclock down
      cbi(PORTB,5);sbi(PORTD,7); //clkpin down, notclock up

The result cut the overall loading time in half and the 1802 interaction is now faster than the PC transmission. I could improve this by further squeezing each of them and/or overlapping them but I think I’m ok with this at least for now. 14-03-10 faster loading

It’s now loading 10k in a bit over 3 seconds. If I pushed the host link to 115kb and overlapped host and 1802 i/o that could be as low as a second which would be pretty sweet so maybe sometime…

The overall loader program is cribbed from a version of the standard bootloader that runs on an arduino and talks to avrdude on the PC. My version of it is pretty crufty but you can see it on the LCC1802 downloads page here: The file name is


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: