[Help] Problem using USBasp to program ATMega 328P

Go To Last Post
53 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Updated:

Hi guys now I did some changes:

  1. bought a new breadbord and bunch of wires

  2. changed my programmer into this model ( but my one without having the 3 male header): 

  3. https://www.ebay.com/itm/USB-AVR...

  4. Changed my IDE into Atmel studio 6

  5. and I changed the tutorial video that I watched, I switched to this video and I watched the video from the first part : https://www.youtube.com/watch?v=...

 

and now I got a response from the avrdude command prompt or output window of atmel studio:

 

 

 

 

 

 

 

 

Now my question is:

  1. how to upload a program if I have this kind of weird new error code , I tried to upload a new program but it only shows that it is on reading stage / process? do you guys know how to solve this problem?

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Tue. Jul 2, 2019 - 01:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As that looks like you are using avrdude then try adding "-v" to the command line to get more info about what is wrong. In fact you can add more than one "-v" to get more and more detail (up to four).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

As that looks like you are using avrdude then try adding "-v" to the command line to get more info about what is wrong. In fact you can add more than one "-v" to get more and more detail (up to four).

So later I'll add another "-v" in my command line. But where should I add it? Because my command line looks like this
"avrdude -c usbtiny -p atmega328p"
Do you have another solution for me? Because I'm scared I can't solve this problem again

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
avrdude -v -v -v -v -c usbtiny -p atmega328p

BTW I assume you have read and done everything documented on:

 

https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide?_ga=2.208512475.832317106.1557745957-1014207791.1542287544

 

(in particular the stuff about Windows drivers you may need to install).

Last Edited: Mon. May 13, 2019 - 11:14 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most AVR programmers do not supply target power, so make sure your m328p has power on all vcc/gnd and avcc/gnd pin pairs before trying to program the part.

And if this is a bare chip, it must also have 100nf bypass caps on each vcc/gnd and avcc/gnd pin pairs!!!!

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

ki0bk wrote:
Most AVR programmers do not supply target power,
However on this occasion....

 

 

wink

 

(of course it does appear to depend on how that switch is actually set - so probably worth checking the state).

Last Edited: Mon. May 13, 2019 - 01:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The other possible cause, is too high of an ISP speed, try 125kHz.

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When using avrdude you may be able to vary that ISP speed using the -B option. Note, however, that this is dependent on the programming firmware in the programmer itself. The 8K USBAsp based programmers often have room in the code for the logic to handle variable ISP speeds (some doing dynamic switching even) but USBTiny based programmers like this one are based on tiny2313 (supposedly makes them cheaper?!?) and it has just 2K of code so the facilities may be more limited.

 

I do wonder why in 2019 anyone would bother with a USBTiny design. Especially one costing €16 on Sparkfun. You can buy USBAsp's on ebay for $2 or less.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry for a totally late reply cause now I have free time and continue my learning purpose. so for my case at atmega 328p, I need to give supply directly to the Vcc/Gnd and AREF/Gnd pairs right? and both of them also must have a bypass caps right?

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The datasheet and AVR040/AVR042 give guidance on best practice. But some fundamental rules are that all power supply pins should be connected as the datasheet dictates and all switching ICs (CPUs etc) should have nearby by 100n decoupling caps to keep their PSU stable even when switching outputs:

 

https://en.wikipedia.org/wiki/Decoupling_capacitor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

so meaning each GND and VCC or GND and AVCC must have a coupling capacitor?

but I follow from this website   https://www.allaboutcircuits.com/projects/breadboarding-and-programming-the-atmega328p-and-attiny45-in-atmel-studio-7/  and it shows that the coupling capacitor is placed between AREF and GND that's why I'm confused

 

EDIT:

currently I got my USBASP from my friend, which one do you guys recommend for a newbie like me?

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Mon. Jul 1, 2019 - 03:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:
it shows that the coupling capacitor is placed between AREF and GND that's why I'm confused

That would be a filter cap, it is optional but a good practice if you use the ADC in your app.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Currently I don't have an ADC application but maybe I'll use it in the future. Now what I want to do is being able to do "hello world" with this microcontroller. Do you have any solution for that?

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How to change the ISP speed? Do you have any guidance for that because I'm a little bit lost

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


rizkifajarnugroho wrote:
How to change the ISP speed? Do you have any guidance for that because I'm a little bit lost

AVRdude user guide:

ISP speed needs to be less than 1/4 the cpu speed, so most AVR's default to 1MHz when factory fresh, so use < 256kHz

-B 125kHz on your command line.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

rizkifajarnugroho wrote:
How to change the ISP speed? Do you have any guidance for that because I'm a little bit lost

AVRdude user guide:

ISP speed needs to be less than 1/4 the cpu speed, so most AVR's default to 1MHz when factory fresh, so use < 256kHz

-B 125kHz on your command line.

 

Jim

 

 

so this is my arguments : -c usbtiny -p m328p -v -v -v -U flash:w:$(TargetDir)$(TargetName).hex:i  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

where do I need to but the -B 125 kHz? because I already put something like this: -c usbtiny -p m328p -B 125kHz -v -v -v -U flash:w:$(TargetDir)$(TargetName).hex:i  -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

and it shows that avrdude.exe: invalid bit clock period specified '125kHz'

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Mon. Jul 1, 2019 - 06:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

any where on the command line, I don't believe it maters where.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

is it in command line or in arguments?

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See Cliffs reply: https://www.avrfreaks.net/commen...

 

Most of us use one of these:  https://www.ebay.com/itm/USB-AVR...

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Mon. Jul 1, 2019 - 07:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

See Cliffs reply: https://www.avrfreaks.net/commen...

 

Most of us use one of these:  https://www.ebay.com/itm/USB-AVR...

 

Jim

 

Edited

 

Hi now I did some changes:

1. change into atmel studio 6

2. change my programmer with an usbasp as the one you suggested except my model don't have the 3 pin male header (my version is MX-USBISP-V3.01)

3. buy a new breadboard and bunch of jumper wires

 

and I have so called a new problem as the command prompt result show this:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e940b
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

 

it seems I can't upload any program to it as the output window of atmel studio show this (see below picture) :

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x1e940b
avrdude.exe: Expected signature for ATMEGA328P is 1E 95 0F
             Double check chip, or use -F to override this check.

avrdude.exe done.  Thank you.

 

do you guys know how to rectify this issue?

 

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Tue. Jul 2, 2019 - 09:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:
do you guys know how to rectify this issue?
The chip clearly is not the chip you think it is !

 

A 1E 94 0B is a mega168P not a mega328p. So change the "-p m328p" part of your command to be "-p m168p"

 

Just out of interest what lead you to think that the chip your are programming is a mega328p anyway? What it actually written on top of the chip? Does it say "328" or "168" ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

rizkifajarnugroho wrote:

do you guys know how to rectify this issue?

 

The chip clearly is not the chip you think it is !

 

A 1E 94 0B is a mega168P not a mega328p. So change the "-p m328p" part of your command to be "-p m168p"

 

Just out of interest what lead you to think that the chip your are programming is a mega328p anyway? What it actually written on top of the chip? Does it say "328" or "168" ?

My current programmer is : MX-USBISP-V3.01

 

Hi yeah just now I realized my mistake that I thought I programmed the ATmega328p and it turned out that I did the connection for ATmega168p

but once I change the command become: C:\Users\rizki>avrdude -c usbasp -p m168p

the response was: avrdude: AVR Part "m168p" not found.

 

 

how to fix the above new error code now? since based on the list of device it is only available for the ATmega 168, not ATmega168p

 

and I realized that I think my ATmega 328p had a problem since now I repeat the same connection as what I did to ATmega 168p and the response still the same:

 

so I believe that my ATmega 328p was spoiled or damaged right since I already tried the following command as others suggested me in this thread

 

 

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Tue. Jul 2, 2019 - 01:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You don't need to specify the isp speed with a Chinese usbasp, it will self adjust, and you can ignore the warning about sck speed avrdude emits. 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

You don't need to specify the isp speed with a Chinese usbasp, it will self adjust, and you can ignore the warning about sck speed avrdude emits. 

 

But then I still get an error code that rc = -1 if I use ATMega 328p and if I use ATmega 168P it shows that the model is not available on the usbasp device list
Please help me about this cause I feel exhausted and a little bit sad

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in the first posting you state or show you are using AS6 and avrdude 5.6???

Why are you using out of date code? 

AS7 and avrdude 6.3 are current versions. 

 

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

in the first posting you state or show you are using AS6 and avrdude 5.6???

Why are you using out of date code? 

AS7 and avrdude 6.3 are current versions. 

 

Jim

Yes this one was the same thread as last time I used the AS7 but I'm not sure which avrdude I used last time
So now I need to go back to the AS7 with AVRDUDE 6.3?

 

1. the following picture is when I want to play with the B or the speed of the ISP

 

 

 

2. the following picture when I just enter a regular command 

 

 

 

3. the following picture is the more detail whereby I put four v alphabets

 

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Tue. Jul 2, 2019 - 01:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok I see you using avrdude 6.3 now, with a usbasp, there is not need to specify isp speed (i.e. -B some number) as the Chinese firmware in the usbasp takes care of that for you.

Your error: target does not answer would tell me your chip has no power, so be sure your have 5v connect to pins VCC and AVCC and both GND and AGND are connect to gnd.

In addition, both power pin pairs need a 100nf cap placed as close to the pins as possible. 

Can you post a picture of your setup, that would help us help you to get it all right.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

Ok I see you using avrdude 6.3 now, with a usbasp, there is not need to specify isp speed (i.e. -B some number) as the Chinese firmware in the usbasp takes care of that for you.

Your error: target does not answer would tell me your chip has no power, so be sure your have 5v connect to pins VCC and AVCC and both GND and AGND are connect to gnd.

In addition, both power pin pairs need a 100nf cap placed as close to the pins as possible. 

Can you post a picture of your setup, that would help us help you to get it all right.

 

Jim

 

 

thanks man for helping me, these are my connection pictures

note that for the wire colour

Red is for Vcc

White and Black for GND

the capacitor that used has 104 written on it which is 0.1 uF or 100nF

orange cable is for MOSI

Blue cable is for MISO

yellow cable is for SCK

grey cable on pin number 1 is a reset

 

1. First picture is ATmega328p connection

 

 

2. The following picture is the view from the pin number 1 of the 2x5 female header

 

3. This the other side view of 2x5 female header is the Vcc and GND located

 

but in my previous picture that I uploaded there was a statement 

 

it showed that "cannot set sck period, please check for the update usbasp firmware update"

is it a problem or just something that I can ignore?

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Tue. Jul 2, 2019 - 02:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:

it showed that "cannot set sck period, please check for the update usbasp firmware update"

is it a problem or just something that I can ignore?

That can be ignored!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

rizkifajarnugroho wrote:

it showed that "cannot set sck period, please check for the update usbasp firmware update"

is it a problem or just something that I can ignore?

That can be ignored!

 

Jim

 

So what are my problems in this case? Can you help me to check out? Just now I remember that this ATmega I took it from my friend's arduino. Is that an issue also?

Embedded Lover and would like to pursue my future in embedded system

Last Edited: Tue. Jul 2, 2019 - 03:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the pic's!  The M328 looks like it's wired correctly,

Verify your 2x5 connector wiring, it's common to get the sides swapped when looking at the bottom of the connector, when the common diagram shows connections from the top side of the connector.

One way to verify is use a volt meter and check your vcc on the chip, if that is correct then the rest are most likely ok as well.  (assuming your vcc comes from the usbasp).

 

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

Thanks for the pic's!  The M328 looks like it's wired correctly,

Verify your 2x5 connector wiring, it's common to get the sides swapped when looking at the bottom of the connector, when the common diagram shows connections from the top side of the connector.

One way to verify is use a volt meter and check your vcc on the chip, if that is correct then the rest are most likely ok as well.  (assuming your vcc comes from the usbasp).

 

Jim

Yes I checked with my voltmeter between each Vcc and GND I got approximately 5 V. So now what changes should I make? I double check my pins from the usbasp that the 5V also appear between the Vcc and GND

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may find one of these to be handy: https://www.adafruit.com/product...

Did your usbasp come with a 10pin to 6pin adapter?

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

You may find one of these to be handy: https://www.adafruit.com/product/1465

Did your usbasp come with a 10pin to 6pin adapter?

 

Jim

 

Ok I'll check that out but I need to make this one work as I really need to study an 8 bit microcontroller as a basic

I do have another adapter from the 10 pin to 6 pin or 10 pin but it comes from the sparkfun

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:
I do have another adapter from the 10 pin to 6 pin or 10 pin but it comes from the sparkfun

That will work with the above protoboard adapter or any 2x3 ISP connector. 

Ok, verify your 2x5 connector connections, hang in there, your close to getting this to work.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:
So what are my problems in this case? Can you help me to check out? Just now I remember that this ATmega I took it from my friend's arduino. Is that an issue also?

 

The ex-Arduino AVR will expect a crystal with 2 22pF capacitors.

It will never work unless you provide crystal and caps.

The obvious solution is to put it back in the Arduino.

Connect the USBASP to the 3x2 ICSP header.

Away you go.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

Just now I remember that this ATmega I took it from my friend's arduino. Is that an issue also?

I missed that, so your M328 has been fused to use an external xtal as its clock source, do as david said and return it to the Arduino and use your programmer to set the fuses to default values,

note, the uno has a jumper that must be cut in order to use an external programmer and restored to use it again with a boot loader. 

I wish I had seen that before! 

Arduino Nano's are SO much easier to use on a bread board!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Tue. Jul 2, 2019 - 03:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

rizkifajarnugroho wrote:
So what are my problems in this case? Can you help me to check out? Just now I remember that this ATmega I took it from my friend's arduino. Is that an issue also?

 

The ex-Arduino AVR will expect a crystal with 2 22pF capacitors.

It will never work unless you provide crystal and caps.

The obvious solution is to put it back in the Arduino.

Connect the USBASP to the 3x2 ICSP header.

Away you go.

 

David.

 

so from that arduino I do the same thing what I've done with the AVRDUDE and AS7? but my friend brought his old arduino board so I can't test it ASAP. I want to try with the ATMega 168p as I have a progress now but below is my new problem because I was too excited and jumped to the AS7 directly

 

 

ki0bk wrote:

rizkifajarnugroho wrote:
I do have another adapter from the 10 pin to 6 pin or 10 pin but it comes from the sparkfun

That will work with the above protoboard adapter or any 2x3 ISP connector. 

Ok, verify your 2x5 connector connections, hang in there, your close to getting this to work.

 

Jim

 

Hi bro sorry just  a quick update, just now I was playing with the ATmega 168p again (comes from the element14 fresh out of the box)

when I enter in the command prompt, I got the result as following: 

 

but my mistake because too happy was directly tried in the ATMEL STUDIO 7 and try to upload with the external tools and I got the result as following (I apologize if I put too many pictures but now I think I spoiled my ATMega 168P because I burned the fuse right?)

 

and then it repeat the same thing until skipping page 127 at the last one

 

and once I checked in the command prompt it become like this again (so sad now)

 

 

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

david.prentice wrote:

Just now I remember that this ATmega I took it from my friend's arduino. Is that an issue also?

I missed that, so your M328 has been fused to use an external xtal as its clock source, do as david said and return it to the Arduino and use your programmer to set the fuses to default values,

note, the uno has a jumper that must be cut in order to use an external programmer and restored to use it again with a boot loader. 

I wish I had seen that before! 

Arduino Nano's are SO much easier to use on a bread board!

 

Jim

 

 

Hmm I'll try to contact my friend to bring his old arduino board but now he is still away and I can't ask it in the ASAP moment. but I want to try with the ATMega 168p that comes from the element14 fresh out of the box. could you see my new problem in the top picture?

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

note, the uno has a jumper that must be cut in order to use an external programmer and restored to use it again with a boot loader. 

I wish I had seen that before! 

Arduino Nano's are SO much easier to use on a bread board!

You can use an external programmer at any time.   You do not cut any jumpers.

 

Of course you need to re-Burn the Bootloader to restore the Arduino to its proper state.

 

You only "cut a solder-bridge" if you want to use debugWIRE on a Uno.

Disable debugWIRE.  Make the solder-bridge.   Burn Bootloader to restore the Arduino to its proper state.

 

I  beg to differ.    I put all external electronics on ProtoShields.    This means that I can just plug into any Arduino target,  STM32 Nucleo, FRDM, ... board.

Actually,   I have just bought two Nano-Every boards.    I have soldered one to a Protoshield.   And the other is plugged into a Nano Adapter board.    So I can plug Shields, Protoshields, ... into either Nano-Every.

 

Yes,  I know that some people like breadboards.    Fine for a one-off lash-up.    Painful if you have to rewire for a fresh target.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have deliberately programmed LFUSE as 0xFF

 

This means that your m168 chip requires a crystal now.

Just like the m328p chip from the Arduino.

 

God invented the Arduino so that you do not ever need an external programmer.

 

Buy yourself a cheap Uno clone and some DuPont cables.    It will make your life easier.

And there are lots of Shields and external modules from Ebay.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

You have deliberately programmed LFUSE as 0xFF

 

This means that your m168 chip requires a crystal now.

Just like the m328p chip from the Arduino.

 

God invented the Arduino so that you do not ever need an external programmer.

 

Buy yourself a cheap Uno clone and some DuPont cables.    It will make your life easier.

And there are lots of Shields and external modules from Ebay.

 

David.

Yes now I think I want to go for the other option which is through the uno clone board. 

I do have the cheap uno clone board, but it comes with the ATMega 328p SMD package. I don't want to use the arduino programming language, I want to handle with the C programming when I control the ATMega 328p on the uno clone board, is that possible? How to do that? 

if I want to use for the project that uses SPI, I2C,  and UART, is the arduino uno clone is sufficient enough for my desire?

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tend to do everything with Uno boards. ASM, C, C++, ...
Always use the bootloader from AS7, Codevisiom, Bascom, ...
Very occasionally I enable debugWIRE and use with ATMEL-ICE.or SNAP
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:
I want to handle with the C programming when I control the ATMega 328p on the uno clone board, is that possible? How to do that? 

There is nothing to stop you from doing that, just use the bootloader to upload your code! 

An arduino uno is JUST a Mega328 with all of the supporting circuits needed to make it easy to run!

It matters not how you create your hex file (Arduio IDE, AS7, CodeVision, ICC or other), have fun. 

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:

I don't want to use the arduino programming language

 

See this article: Using the Arduino IDE Without Cores

--Mike

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need to give supply directly to the Vcc/Gnd and AREF/Gnd pairs right?

Just to be certain, the above is USUALLY incorrect.

 

Although one can, on occasion, connect Vcc to ARef, that is not the usual practice. 

ARef can be left open, nothing connected to it, if you are not using the ADC or AC modules on the micro.

If you wish to use the analog modules, then connect a cap on ARef to ground, (typically 0.1 uF).

 

If you wish to use Vcc as the reference voltage for the ADC, AC, (DAC... (on some chips)), then you would usually select that option via the bits in a setup register and just have a cap on the ARef pin.

 

If one hard wires the Vref to Vcc, and then the software internally configures the reference to another value, it can fry the ADC section of the chip, (and/or the entire chip).

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:
I need to give supply directly to the Vcc/Gnd and AREF/Gnd pairs right?
Don't confuse AREF with AVCC.  AVCC must be connected and decoupled, with an optional L between VCC and AVCC.  AREF should be used as DocJC has described.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

I tend to do everything with Uno boards. ASM, C, C++, ...
Always use the bootloader from AS7, Codevisiom, Bascom, ...
Very occasionally I enable debugWIRE and use with ATMEL-ICE.or SNAP
.
David.

Ok I'm going to start to program the atmega 328p with the help of Arduino board and now I able to turned off or on an LED with AS7, but I got an additional question because the Arduino atmega 328p has a clock speed of 16MHz as the following picture show and I want to follow the programming/project tutorial from the book "Make: AVR Programming" by Elliot Williams , will it cause a problem because I assume that my Arduino atmega 328p works too fast.  And I saw that in the sample code that the book gave they mention about this statement: #define F_CPU = 1000000UL

Please enlighten me about this issue. 

ki0bk wrote:

rizkifajarnugroho wrote:

I want to handle with the C programming when I control the ATMega 328p on the uno clone board, is that possible? How to do that? 

 

There is nothing to stop you from doing that, just use the bootloader to upload your code! 

An arduino uno is JUST a Mega328 with all of the supporting circuits needed to make it easy to run!

It matters not how you create your hex file (Arduio IDE, AS7, CodeVision, ICC or other), have fun. 

 

Jim

 

Yes, now my hello word is succeeded already and I was very happy with this. But I have an additional problem because the 

because the Arduino atmega 328p has a clock speed of 16MHz as the following picture show and I want to follow the programming/project tutorial from the book "Make: AVR Programming" by Elliot Williams , will it cause a problem because I assume that my Arduino atmega 328p works too fast. Please enlighten me about this issue. And I saw that in the sample code that the book gave they mentioned  about this statement:

#define F_CPU = 1000000UL

 

Please enlighten me about this issue. 

 

avr-mike wrote:

rizkifajarnugroho wrote:

 

I don't want to use the arduino programming language

 

See this article: Using the Arduino IDE Without Cores

--Mike

 

 

Sure thanks man but I have an additional issue that I mentioned above section of my reply, please help me to answer that 

 

DocJC wrote:

I need to give supply directly to the Vcc/Gnd and AREF/Gnd pairs right?

Just to be certain, the above is USUALLY incorrect.

 

Although one can, on occasion, connect Vcc to ARef, that is not the usual practice. 

ARef can be left open, nothing connected to it, if you are not using the ADC or AC modules on the micro.

If you wish to use the analog modules, then connect a cap on ARef to ground, (typically 0.1 uF).

 

If you wish to use Vcc as the reference voltage for the ADC, AC, (DAC... (on some chips)), then you would usually select that option via the bits in a setup register and just have a cap on the ARef pin.

 

If one hard wires the Vref to Vcc, and then the software internally configures the reference to another value, it can fry the ADC section of the chip, (and/or the entire chip).

 

JC

 

Hmm I think I'll get back to you in the future when I apply and use the ADC because now I'm still at the starting of the basic part

 

joeymorin wrote:

rizkifajarnugroho wrote:

I need to give supply directly to the Vcc/Gnd and AREF/Gnd pairs right?

 

Don't confuse AREF with AVCC.  AVCC must be connected and decoupled, with an optional L between VCC and AVCC.  AREF should be used as DocJC has described.

 

Sure noted now I learnt a new stuff thanks for you guys and this community I love it because everyone is helping each other

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rizkifajarnugroho wrote:

Yes, now my hello word is succeeded already and I was very happy with this. But I have an additional problem because the 

because the Arduino atmega 328p has a clock speed of 16MHz as the following picture show and I want to follow the programming/project tutorial from the book "Make: AVR Programming" by Elliot Williams , will it cause a problem because I assume that my Arduino atmega 328p works too fast. Please enlighten me about this issue. And I saw that in the sample code that the book gave they mentioned  about this statement:

If you copy-pasted from the book,   the book is cr*p.

The define statement should be like this:

#define F_CPU 1000000UL

i.e. without the =

 

No,  it is no problem to run the 1MHz examples on your 16MHz Uno.   You just add

...
#include <avr/power.h>
...
int main(void)
{
    clock_prescale_set(clock_div_16);  //run your 16MHz hardware at 1MHz
    ...
}

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

rizkifajarnugroho wrote:

Yes, now my hello word is succeeded already and I was very happy with this. But I have an additional problem because the 

because the Arduino atmega 328p has a clock speed of 16MHz as the following picture show and I want to follow the programming/project tutorial from the book "Make: AVR Programming" by Elliot Williams , will it cause a problem because I assume that my Arduino atmega 328p works too fast. Please enlighten me about this issue. And I saw that in the sample code that the book gave they mentioned  about this statement:

If you copy-pasted from the book,   the book is cr*p.

The define statement should be like this:

#define F_CPU 1000000UL

i.e. without the =

 

No,  it is no problem to run the 1MHz examples on your 16MHz Uno.   You just add

...
#include <avr/power.h>
...
int main(void)
{
    clock_prescale_set(clock_div_16);  //run your 16MHz hardware at 1MHz
    ...
}

David.

 

so everytime inside my program I must put the statement that you explained right? now I understand and will start tomorrow when I'm in the school lab ( I don't have so much resources, so I'm dependent on them) 

thank you for your help and will get to you back later if I have the problem with the clock speed

 

Embedded Lover and would like to pursue my future in embedded system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is quite a good habit to get into.  i.e. including power.h in every program

Then you can prescale your clock speed safely e.g. use clock_div_1 when you want to run at full speed.

 

It also works with virgin chips.   They come out of the factory with 8MHz RC but the fuse is set for CLKDIV8.

 

Using clock_div_1 will ensure that you run at 8MHz whether CLKDIV8 fuse is set or not.

 

David.

Pages