Forum Discussion
Altera_Forum
Honored Contributor
16 years agowrite char in DE2 SRAM
hello,
Sorry I'm a newbie in NIOSII... I would like to write and read a char in the SRAM, I try to use itoa function but NIOSII doesn't recognize this function? I use this command: IOWR_16DIRECT((SRAM_BASE), 4, "a"); value = IORD_16DIRECT((SRAM_BASE), 4); printf("%d,%s\n", 4,value); How can I write a char in SRAM whithout itoa function please? Thx.5 Replies
- Altera_Forum
Honored Contributor
I've tested your code....
I would like to know how you can read this char using IORD_16DIRECT ? How do you write a char as "abcd" at a specific adress ? Thanks for your help. - Altera_Forum
Honored Contributor
ok thx i'll try it.
I've one more question about that... what's the ".sram" ? cuz the sram that i use is a new component that i've created in SOPC builder...would like to know if this name should be linked with the name of the component.... Thx - Altera_Forum
Honored Contributor
For declaring an initialized string at sram use:
my_str must be global. This, assuming you have a sram object. For copying between memory locations just use memcpy().char my_str __attribute__ ((section (".sram"))) = "abcde"; - Altera_Forum
Honored Contributor
if i wanna write a char for exemple "abcd" what can i do ?
thx - Altera_Forum
Honored Contributor
Non standard itoa() function is for convert an integer to a string, it is not related to SRAM,
If you want convert numbers to string just use standard function sprintf(). If you want write a single char, use simple quotes 'a', not double quotes "a".