NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Should libnerdkits/uart.h work on a MCU without bootoader?

April 18, 2010
by JackScumm
JackScumm's Avatar

Hi,

One of the first things I did with my kits was to try controlling LEDs from my PC as described in this post by Nerdful_com This all worked without any problems. Then I got myself an Avrisp MK2 programmer, did some simple stuff with it, all well so far.

Then I tried the control LEDs again. This time copy/pasting the code to AVR Studio and using Avrisp to program my MCU. It compiles and the programmer programs the chip, but when I try it, it doesn't work.

I have double checked everything and all seems be OK. I'm guessing here, but could it be that when I program my MCU using Avrisp, it erases the chip thus removing the bootloader, which is needed for uart.h to work properly?

Help much appreciated.

/Jack

April 19, 2010
by Rick_S
Rick_S's Avatar

I didn't notice the code :

#include "../libnerdkits/uart.h"

at the top of that program listing. It may have worked with the bootloader because the bootloader initializes the UART itself.

Add that at the top with your includes and see if it works.

Hope that helps,

Rick

April 19, 2010
by JackScumm
JackScumm's Avatar

The include is there. Without the include it wouldn't compile.

April 19, 2010
by treymd
treymd's Avatar

This is an area I am pretty interested in, how are your fuses set?

April 19, 2010
by JackScumm
JackScumm's Avatar

I don't understand anything about fuses, but this is what AVR Studio says. Extended 0xF8 High 0xD5 Low 0xF7 Lockbit 0xFF

April 19, 2010
by Rick_S
Rick_S's Avatar

I apologize for the earlier comment... Had just gotten up and apparently didn't read your post topic or Nerdful's program very well :)

Unless they've changed, the fuse settings you show aren't standard fuse settings for a Nerdkit MCU. Is that another MCU you purchased elsewhere?

Normal Nerdkit fuse settings for an ATMEGA168 are:

Lock:      0x2F
Extended:  0x00
High:      0xD5
Low:       0xF7

And for an ATMEGA328p are:

Lock:      0x2F
Extended:  0x05
High:      0xD2
Low:       0xF7

Not that those settings should affect your UART issue.

You can find detailed descriptions of what each of the fuse/lock bits do in the Datasheet under memory programming (on my revision it's section 27).

I haven't tried Nerdful's program but don't see any reason why it would not run on an mcu without a bootloader. Did you change the code any from what you used with the bootloader vs. ISP programmed? If the code is different, could you post it??

Sorry I couldn't be of more help. Maybe someone else will chime in.

Rick

April 20, 2010
by mcai8sh4
mcai8sh4's Avatar

Hi JackScumm, assuming you haven't changed the code (except the Makefile), then it should work - but remember you will still need to use the Nerdkits header to communicate with your computer. If your ISP has to connect to pins 2 and 3, then you may have to remove the ISP programmer from the chip.

If that doesn't work... maybe a quick photo might help us.

Keep us posted on your progress.

Steve

April 21, 2010
by JackScumm
JackScumm's Avatar

Seems there's something wrong with my programmer or how I use it.

I have made some really simple tests. Wrote code that set all pins on port B as output and then turn them all on. Nothing fancy. This is all fine with AVR Studio and even the simulator works as expected. Then I use my Avrisp mk2 to upload it to the chip. It uploads nice, no problems everything is fine. But when I unplug the programmer and turn on power to the board again, nothing happens. No LED is turned on. I have tried this with three different MCUs, ATMega168, ATMega88 and ATTiny85. Same result with them all. Nothing happens. Worth noting is that this has worked before. I have successfully uploaded this same simple test to my ATTiny85 and got the LEDs to light up.

I'm gonna do some googling, let's see if I find something...

/Jack

April 25, 2010
by JackScumm
JackScumm's Avatar

Some progress, got the simple LED thingy to work. Rather embarrassing root cause... always make sure that you upload the file you actually intended to upload. It appears that I was uploading the same faulty file over and over.

The UART problem still remains. An interesting observation is that when no power is supplied to the board and I connect GND and yellow on my USB cable, I get a faint glow on the LED. Have i borked my USB cable?

April 25, 2010
by JackScumm
JackScumm's Avatar

w00t, problem solved!!

My fuses were wrong, had wrong value for SUL_CKSEL.

Correct value is "Ext. Full-swing Crystal; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms" when using the same crystal oscillator as supplied with the kit. I have no idea what that really means but no matter :D

/Jack

Post a Reply

Please log in to post a reply.

Did you know that Pulse Width Modulation (PWM) can be used to control the speed of a motor digitally? Learn more...