嵌入式操作系统
FUNCTION NUMBER | FUNCTION NAME | ENTRY POINT | SUMMARY |
0 | flashWrite | 08461h | Programs a single word of flash memory. |
1 | flashErasePage | 08467h | Erases (programs to FFFFh) a 256-word sector of flash memory. |
2 | frashEraseAll | 08478h | Erases (programs to FFFFh) all flash memory. |
3 | moveDP0 | 08487h | Reads a byte/word at DP[0] |
4 | moveDP0inc | 0848Ah | Reads a byte/word at DP[0], then increments DP[0]. |
5 | moveDP0dec | 0848Dh | Reads a byte/word atDP[0], then decrements DP[0]. |
6 | moveDP1 | 08490h | Reads a byte/word at DP[1]. |
7 | moveDP1inc | 08493h | Reads a byte/word at DP[1], then increments DP[0]. |
8 | moveDP1dec | 08496h | Reads a byte/word at DP[1], then decrements DP[0]. |
9 | moveFB | 08499h | Reads a byte/word at BP[Offs]. |
10 | moveFPinc | 0849Ch | Reads a byte/word at BP[Offs], then increments Offs. |
11 | moveFPdec | 0849Fh | Reads a byte/word at BP[Offs], then decrements Offs. |
12 | copyBuffer | 084A2h | Copies LC[0] values from DP[0] to BP[Offs]. |
-DThe=
extern void utilFlashWrite(void); extern void utilFlashErasePage(void); extern void utilMoveDP0(void);
__no_init volatile __io unsigned int A0 @ _M(0x09,0x00);Pay special attention to the data type and inputs to the _M macro. This variable, A0, was declared as "unsigned int" because it is a 16-bit register. If it were an 8-bit register, we could have declared it as an "unsigned char." The inputs to the _M macro are the module number followed by offset of the A[0] register. Now you can simply set this variable to the value you want in A[0].
A0 = pageAddr;
MAXQ10 Devices | MAXQ20 Devices |
A[0], A[1], A[2], A[3], GR, LC[0], LC[1], DP[0], BP, OFFS, AP | A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], GR, LC[0], LC[1], DP[0]. BP, OFFS, AP |
return (PSF_bit.C == 0);
unsigned char origIGE = IC_bit.IGE; // Save current state. __disable_interrupt(); /* Add UROM call code here. */ IC_bit.IGE = origIGE; // Restore interrupt state.If you follow all of these steps, you will have code that looks similar to the following:
#include#include // Prototype for the real Utility ROM function. extern void utilFlashErasePage(void); // Define the register we need direct access to. __no_init volatile __io unsigned int A0 @ _M(0x09,0x00); unsigned char flashErasePage(unsigned int page) { unsigned int pageAddr; unsigned char origIGE; pageAddr = page << 8; // Change page # to an address. origIGE = IC_bit.IGE; // Save current state. __disable_interrupt(); A0 = pageAddr; // Set up input to UROM function. asm("push APC"); // UROM function destroys APC. utilFlashErasePage(); // Call actual UROM function. asm("pop APC"); // Restore APC. IC_bit.IGE = origIGE; // Restore interrupt state. return (PSF_bit.C == 0); // Check return code from UROM. }
IAR Embedded Workbench is a registered trademark of IAR Systems AB.
MAXQ is a registered trademark of Maxim Integrated Products, Inc.
全部0条评论
快来发表一下你的评论吧 !