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.

character string array in AVR Studio (AVR GCC)

Status
Not open for further replies.

ark5230

Advanced Member level 3
Advanced Member level 3
Joined
Jun 29, 2009
Messages
862
Helped
163
Reputation
324
Reaction score
140
Trophy points
1,323
Location
India
Visit site
Activity points
6,187
I am new to C and C++ but trying to use with AVR.
I am trying to use character string array like
a[1]="Name - 1"
a[2]="Name - 2"
a[3]="Name - 3"
a[4]="Name - 4"

Any resource or suggestion to declare and use such subscripted character string variable.
Storing in program memory or RAM will do.
If all goes will I wish to use it with EEPROM, I checked and test use of EEPROM with simple data.
 

To declare an array of null terminated strings in C you can use

Code:
char my_ram_array_of_strings[][9] = { 	"Name - 1",
					"Name - 2",
					"Name - 3",
					"Name - 4"};

The characters can then be acceded using my_ram_array_of_strings[y][x] where y is the vertical position (starting from 0 which is the top string) and x which is the horizontal position (starting from 0 which is the leftmost character)



Check
https://pages.cpsc.ucalgary.ca/~jacob/Courses/Fall00/CPSC231/Slides/10-ArraysAndStrings.pdf
 
Thanks a lot for complete and useful answer, It solved my current problem.
As mentioned in first mail, if I go for EEPROM with little larger number of elements, is it possible to define number of element in declaration and that too without initialising. I will carefully go through the PDF, this may also give some hint of direction.
It compiles however it seems it is accessing the character at [y] [x] and not the array at a time.
 

Thanks a lot, this is great stuff, I will print and study. This will help resolve many future issues. However if I dont understand a specific issue, I will post the same. I will try to avoid use of string type and try to modify code to implement the desired functionality using character arrays.
 

I think Atmel studio 6 supports C++ which will give you additional features but I have no knowledge of C++ so I can't help you and usually it is not a good idea to use it for small microcontrollers because of the limited resources
 
I am using Atmega32.
Atmel studio 6
This refers to AVR Studio 6 or it is different, I am using AVR Studio 4, it supports C++ and is freely available, but dont know if AVR Studio 6 is freely available, will find out from Atmel Site.

I have no knowledge of C++ so I can't help you
You have already helped me out (also earlier in different areas on this forum)
Thanks again
 

avr studio 4 is the older version, actually the one that I still use with winavr.
The latest version of the suite is version 6 and its also free, it also includes the Atmel framework which is Atmels version of winavr so there is no need to install winavr.
There is also version 5 but avoid it.

For older devices like the one you use both version 4 or 6 will work fine, for some new devices you will have to use v6.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top