Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] array intialize problem (avr-gcc)

Status
Not open for further replies.

firewhale

Junior Member level 1
Joined
Oct 14, 2012
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,398
i have a big problem when using array
the array works until my array is 4
but after i add 5th number, avr started joking....
the program very easy & problem seems very old


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/pgmspace.h>
 
int main(void)
{
    uint8_t i = 0;
 
    const uint8_t j[] =
    {
    0x00,0x01,0x02,0x03,0x04,
    };
    DDRB  = 0xff;
    PORTB = 0x00;
 
    for(i=0;i<4;i++)
    {
    PORTB=j[i];
    _delay_ms(500);
    }
}


& ex:when i remove 5th value, array restore correctly
with or without PROGMEM program not change
 
Last edited by a moderator:

Try using a fixed size array, such as
Code:
const uint8_t j[5] =
    {
    0x00,0x01,0x02,0x03,0x04,
    };
 

not change with static or fix array...
joking like joke... i think it....
sorry for bad English
 

provide a minimum code that reproduces the error and what we should do to get the error you mention
 

this means you have no same problem...?
 

The provided code doesn't show any problem for me

Snap1.jpg

when I run it in the debugger and vie the content of j I see all five values as expected.


Note that the condition in the "for" loop

Code:
for(i=0;i<4;i++)
    {
    }

Will only be executed four times (i=0,1,2,3) and not five, I wonder if this is the problem you refer to.
 

maybe makefile are diffrent...?
my problem is:
with 4 value{start show me correct value on led}
with 5or more{ from start show me evrything (65,84,0 0 0 ,....)& dont stop ,never(without loop).}
it seems my avr go crayzy with 5 value.....
can you attach your makefile.
 

I use AVR studio which generates the make file automatically.
I'm attaching the project which includes the make file (mcu is mega8)
 

Attachments

  • conns.zip
    10.5 KB · Views: 79

no, no, no, no,
i can't use your make file

Code Bash - [expand]
1
make: *** No rule to make target '../conns.c', needed by 'conns.o'.  Stop.


when i use

Code C - [expand]
1
PORTD=j[4];


code work well,ofcurse output seems be convert to inline(becuse output hex are incrase)
your code work well ,you&me use avr-gcc but what does linker to me ,why?
 

I'm using AVR studio and winavr(installed separately), where does your avr-gcc installation come from?

- - - Updated - - -

Can you attach your make file?
 

You have Atmel studio installed? Which version?
You are using the integrated tool chain right? (no separate avrgcc installed)
 

So you have installed winavr?
Do you have the latest version?
 

only avr-gcc . no winavr no avr-studio
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top