Beyond the Arduino - AVR article

Post Reply
Selmaware
Posts: 2
Joined: Wed Feb 25, 2015 11:40 am
Contact:

Beyond the Arduino - AVR article

Post by Selmaware »

I guess this is a series, but the first article does not address how the Arduino boot loader is programmed into the AVR before downloading a sketch? Maybe there's something I missed or does it assume we pull one from an Uno?

I am looking forward to more in this series as I teach AVR programming in Assembly/C and as the Arduino and it's good to see someone delving deeper into the AVR microcontroller.

Sincerely,
Martin H.
User avatar
dacflyer
Posts: 4748
Joined: Fri Feb 08, 2002 1:01 am
Location: USA / North Carolina / Fayetteville
Contact:

Re: Beyond the Arduino - AVR article

Post by dacflyer »

sorry about double post... this site is very slow last few days..
User avatar
dacflyer
Posts: 4748
Joined: Fri Feb 08, 2002 1:01 am
Location: USA / North Carolina / Fayetteville
Contact:

Re: Beyond the Arduino - AVR article

Post by dacflyer »

from what i understand is,,, the boot loader has to be loaded on the chip before you can use it..
(if it is a new chip, if you have a new Arduino, it is already on it ) if you replaced the chip, you will need to install the bootloader, unless you buy one that has it already pre-programed on it for you

i did find this on the Arduino site..
Burning the Bootloader..................................

To burn the bootloader, you'll need to buy an AVR-ISP (in-system programmer), USBtinyISP or build a Parallel Programmer. The programmer should be connected to the ICSP pins (the 2 by 3 pin header) - make sure you plug it in the right way. The board must be powered by an external power supply or the USB port.

Make sure you have the right item selected in the Tools | Board menu. Then, just launch the appropriate command from the Tools > Burn Bootloader menu of the Arduino environment. Burning the bootloader may take 15 seconds or more, so be patient.


here is the page i got the info from..
http://arduino.cc/en/Hacking/Bootloader

.
User avatar
aretallack
Posts: 28
Joined: Tue Oct 14, 2014 12:51 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by aretallack »

Thanks for the interest in the series @Selmaware.

I should have been clearer on the bootloader. @dacflyer is right, you can either buy an ATmega328P with a bootloader already loaded (or use the microcontroller from your Arduino UNO), or burn the bootloader onto a new ATmega328P.

I had put together a step-by-step to burn a bootloader using your Arduino UNO - similar to the one on the link @dacflyer included. Take a look at http://www.crash-bang.com/resource/bootload-atmega328/ - hopefully it helps.

-Andrew
----------------------------------------------------
Andrew Retallack
Crash-Banger, Prototyper, Designer, Developer, Author
Selmaware
Posts: 2
Joined: Wed Feb 25, 2015 11:40 am
Contact:

Re: Beyond the Arduino - AVR article

Post by Selmaware »

Thanks much, I was simply ensuring there wasn't a hole in my knowledge somewhere as I teach Arduino and AVR programming. Keep up the good work.

Martin
robralston
Posts: 8
Joined: Fri Apr 24, 2015 5:09 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by robralston »

Thank you for the articles.

Been having trouble getting into Atmel Studio. You paved the way: set for Release and Start without Debugging. I never would have thought about using that last command.

Bought an AVRISPmkII from Atmel but didn’t pay attention to the shipping costs so I really did pay, almost half the cost in shipping. Yes, it really did arrive fast, in two days from Malaysia.

Had a bunch of trouble getting the programmer to consistently talk to my breadboarded 328. Finally plugged the AVRISP directly into one of my Dell 3.0 USB ports rather than going through a 3.0 hub. Problem gone.

I’m assuming that the two statements below really are equivalent, just a matter of style preference ??

(0<<3) or ~(1<<3)
User avatar
aretallack
Posts: 28
Joined: Tue Oct 14, 2014 12:51 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by aretallack »

robralston wrote:Thank you for the articles.
Been having trouble getting into Atmel Studio. You paved the way
Excellent! It's not that hard once you get stuck in, and so much more flexibility and control. I'd never go back :cool:
Bought an AVRISPmkII from Atmel but didn’t pay attention to the shipping costs so I really did pay, almost half the cost in shipping. Yes, it really did arrive fast, in two days from Malaysia.
Yeah, I know how you feel! Here in South Africa shipping costs are crazy - and courier is the only reliable way to get hardware inside of 6 weeks!
I’m assuming that the two statements below really are equivalent, just a matter of style preference ??

(0<<3) or ~(1<<3)
It looks like it should be the same but it's not really:

Code: Select all

(0<<3)   = 00000000
~(1<<3)  = 11110111
If we split the ~(1<<3) into its two component operations:

Code: Select all

~(1<<3) = ~(00001000)   //First we shift the 1 three places left
        = 11110111     //Then we "not" the result
Thanks for the post - keep them coming!

-Andrew
----------------------------------------------------
Andrew Retallack
Crash-Banger, Prototyper, Designer, Developer, Author
robralston
Posts: 8
Joined: Fri Apr 24, 2015 5:09 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by robralston »

Yes, now I understand the difference between (0<<3) or ~(1<<3).

I appreciate your answering questions; I'm going to have a lot of them. Reading the data sheet raises many questions.

re Listing 1 in article 2:

- Program works with the given coding.

Then, when I comment out DDRB &= ~(1<<DDB1); it still works. I'm assuming this is because on power up all of the pins are configured as input, so making B1 an input is not necessary, although certainly good programming. True ?

When I comment out PORTB |= (1<<PORTB1); then the program no longer works, the LED spends time both on and off. However, having removed the internal pull up resistor, if I then attach an external pull up, the program again works. So that makes sense.
robralston
Posts: 8
Joined: Fri Apr 24, 2015 5:09 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by robralston »

Yes, now I understand the difference between (0<<3) or ~(1<<3).

I appreciate your answering questions; I'm going to have a lot of them. Reading the data sheet raises many questions.

re Listing 1 in article 2:

- Program works with the given coding.

Then, when I comment out DDRB &= ~(1<<DDB1); it still works. I'm assuming this is because on power up all of the pins are configured as input, so making B1 an input is not necessary, although certainly good programming. True ?

When I comment out PORTB |= (1<<PORTB1); then the program no longer works, the LED spends time both on and off. However, having removed the internal pull up resistor, if I then attach an external pull up, the program again works. So that makes sense.
User avatar
aretallack
Posts: 28
Joined: Tue Oct 14, 2014 12:51 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by aretallack »

robralston wrote:Yes, now I understand the difference between (0<<3) or ~(1<<3).

I appreciate your answering questions; I'm going to have a lot of them. Reading the data sheet raises many questions.
Those datasheets! Happy to help, it takes a while to start thinking like someone who spends a living writing datasheets... :)
re Listing 1 in article 2:

- Program works with the given coding.

Then, when I comment out DDRB &= ~(1<<DDB1); it still works. I'm assuming this is because on power up all of the pins are configured as input, so making B1 an input is not necessary, although certainly good programming. True ?
Correct, well picked up! Code is redundant when at the start of an application, but I like getting into the habit of not assuming a given state.
When I comment out PORTB |= (1<<PORTB1); then the program no longer works, the LED spends time both on and off. However, having removed the internal pull up resistor, if I then attach an external pull up, the program again works. So that makes sense.
If you're looking at Listing 1 of article 2 then I'm afraid I'm lost - I can't see where anything is being done to PORTB1?

Cheers
Andrew
----------------------------------------------------
Andrew Retallack
Crash-Banger, Prototyper, Designer, Developer, Author
robralston
Posts: 8
Joined: Fri Apr 24, 2015 5:09 pm
Contact:

Re: Beyond the Arduino - AVR article

Post by robralston »

Andrew,

I was testing whether turning on the internal pull up resistor on pin B1 mattered so I commented out /* PORTB |=(1<<PORTB1) */ It does.

With that internal pull up resistor not activated, the LED just "strays" between on and off. But adding an external pull up makes the program work again.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests