atmega128A. programming problem with ASF atmel studio 7 and AVR ISP MKII

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello All, 

i'm tired trying to blink LEDs on my custom board based on atmega128A. i'm using atmel studio 7 with ASF library and AVR ISP MKII programmer on windows 10. and i don't know where i'm doing wrong.

my hardware :has only 1 Atmega128A, and two LED connected to PIN PB5 and PB6, i'm sure MKII programmer pins are well connected to RESET, PB1(SCK) PE1(MISO), PE0(MOSI) because i can read device ID from Atmel Studio7 and program fused. no crystal is connected to xtal1 and xtal2. and i want to use internal osc. From my point of view i think fuses are well programmed to used internal osc. but it seems that the program is not loaded when i press F5.

 

someone can help me to know why ? you will see details of code and screen shot attached. Thanks in advance 

Attachment(s): 

ok

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

The critical fuse is the m103c fuse. By default this makes the mega138 a mega103. You don’t want this. Change it

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

HELLO thanks for your rapid answer but i set Fuses as image attached but it's still not working :)  fuses configuration are correct ? 

 

Attachment(s): 

ok

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

at first glance in your code you suggest that you have set it up as if hte CPU is running at 16MHz.....

but your fuse setting states 1MHz internal RC.

If that is true your processor will be running at 1/16th of the speed you think it is running at, so instead of a led status change every second it is every 16 seconds.....

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


dhino wrote:
image attached

rather than attach, it's better to embed it in the post - so that we can see it in context:

 

 

See Tip #1 in my signature (below; may not be visible on mobile):

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dhino wrote:
i'm using atmel studio 7 with ASF library and AVR ISP MKII programmer on windows 10.
Versions of all?

Windows 10 (edit: winver)

Atmel Studio 7

ASF

AVRISP mkII (Atmel?  Clone?  Function-like?) (reason : some are more complete, precise, and correct)

dhino wrote:
i'm sure MKII programmer pins are well connected to RESET, PB1(SCK) PE1(MISO), PE0(MOSI) because i can read device ID from Atmel Studio7 and program fused. ... but it seems that the program is not loaded when i press F5.
Signature and fuse data is very short relative to a flash block page; sometimes the AVR will brownout during flash write as the AVR will somewhat briefly pull several hundred milliamps from VCC.

AVR VCC's regulator can be evaluated for

  • stability
  • noise
  • efficiency

AVR's NVM controller is a practical step load for the voltage regulator; most regulators are conditionally stable.

USB VBUS can be an practical source of noise.

Swap a conditionally stable power supply for an unconditionally stable power supply (battery or cell, noise is very low frequency due to discharge)

AVRISP can be decoded via a logic analyzer, can scope AVR VCC

dhino wrote:
someone can help me to know why ?
need data such that will transform into information (data with meaning)

May you create joy!

 


ATmega128A - 8-bit AVR Microcontrollers

 

re conf_clock.h

https://asf.microchip.com/docs/latest/common.services.basic.ioport.unit_tests.atmega256rfr2_atmega256rfr2_xplained_pro/html/conf__clock_8h.html

 

Protocol decoders - sigrok

AVR ISP

 

edit2 : strikethru

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Tue. Jan 14, 2020 - 04:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hello, 

Thanks you all for yours  help. 

Today i realize something funny.

the problem is not my costum hardware and also not fuse bit configuration. :) very funny 

The problem is ASF function which does not work and i dont know why ... lol 

 

When i address directly Atmega128A PORTs, and registers, i can even blink an LED, but when i use asf gpio functions it does not work.

 only delay function works when i set F_CPU manually to a value.

 

This is the code which DOES NOT WORKS

 

and THIS CODE WORKS my LEDs blinks and function delays works when i set F_CPU to 1000000

 

you can see the Fuse configuration. 

 

why GPIO function for ASF does not works ? that is the question.

 

ok

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

Why are you not just writing your own program?  ASF is usually a long ride to nowhere.

 

You can write about 8 lines of code & have your led up & blinking away

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Feb 22, 2020 - 04:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Of course that's the question to answer when starting a new project. developping from zero or use something existing in order to gain time.

it's a question of a time. i wanted to go faster and finally i lost a ot of time.

ok