IAR C, how to read a word from program memory?

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

AVRGCC is using pgm_read_word for reading a word from program memory. How can be done the same in IAR C?

Learn as long as you live

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

attribute: __flash
pointer size: 2 bytes
memory space: code
address range: 0x0000 - 0xFFFF
max object size: 32 Kbytes

/* pointer to variables in flash memory */

int __flash *point;

/* variable in flash memory */

int __flash var;

/* intrinsic functions */

#include 

// returns one byte from code memory
unsigned char __load_program_memory(unsigned char __flash *)

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

__load_program_memory is for return one byte, right?

How can return a word (2 bytes);

Learn as long as you live

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

You could make a small function and using the __load_program memory intrinsic twice, return a word.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

ok, thank you. I will follow your way.

Learn as long as you live