How to read specific address

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to read specific address

1,312 次查看
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

标签 (1)
0 项奖励
回复
2 回复数

665 次查看
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 项奖励
回复

665 次查看
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 项奖励
回复