How to read specific address

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read specific address

1,310 Views
Leinmi
Contributor I

I'm only beginner using Freescale microcontrollers, so forgive me for my question. I'm sure it is trivial to most of you.

I'm useing MC68HC908QY4A microcontroller. I'd like to know how can i, using C-language, read specific memory address. The purpose is to store the value from that address to variable. Lets say that I vant to read FLASH memory address $FFC0 an dsore the factory set oscillator trimming value to a variable OSCTRIM. How will I do this (with C-language)?

 

Regards,

 

Leinmi

Labels (1)
0 Kudos
Reply
2 Replies

663 Views
bigmac
Specialist III

Hello Leinmi, and welcome to the forum.

 

Also keep in mind that, if you have created a CW project that will indirectly include the CW header file for the MCU (mc68hc908qy4a.h), this work has already been done for specific addresses in flash.  For the address 0xFFC0, a macro has been defined with the name Optional.  Also the control register OSCTRIM is already defined as the usual destination address.

 

OSCTRIM = Optional;

 

should give the expected result.

 

Regards,

Mac

 

0 Kudos
Reply

663 Views
belskyc
Contributor III

Hello Leinmi,

One way you could try is the following (for 8-bit registers):

 

#define  REGISTER_NAME   (*((unsigned char*)   (0xFFC0)));

...

unsigned char foo;

foo = REGISTER_NAME;

 

The definition statement simply defines "REGISTER_NAME" to point to the value at address 0xFFC0.  Then a declared variable of the same size (8-bit) can simply be assigned to the value of REGISTER_NAME.

 

~belskyc

 

0 Kudos
Reply