|
代码 如下
//******************************************************************************
// MSP430F54x Demo - Reset on Invalid Address fetch, Toggle P1.0
//
// Description: This program demonstrates how a reset is executed if the CPU
// tries to fetch instructions from within the module register memory address
// range (0x0100 --0x0FEF) or from within unused address ranges. Toggle P1.0
// by xor'ing P1.0 inside of a software loop that ends with TAR loaded with
// 3FFFh - op-code for "jmp $". This simulates a code error. The MSP430F5438
// will force a reset because it will not allow a fetch from within the address
// range of the peripheral memory, as is seen by return to the mainloop and
// LED flash.
// ACLK = n/a, MCLK = SMCLK = default DCO ~1.045MHz
//
// MSP430F5438
// -----------------
// /|\| |
// | | |
// --|RST |
// | |
// | P1.0|-->LED
//
// W. Goh
// Texas Instruments Inc.
// November 2008
// Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "msp430x54x.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer - SET BREAKPOINT HERE
P1DIR |= 0x01; // Set P1.0 to output direction
TA0R = 0x3FFF; // Valid opcode (for "jmp $")
while(1)
{
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
__delay_cycles(50000); // Delay loop
// C code to directly call an address location
((void (*)())0x350)(); // Invalid fetch ("call #0350h")
/* 0x350 is address of TA0R register and is within the module register memory
address range (0x0100 --0x0FEF) */
}
}
这段代码 有点 不懂啊、、、
谁能帮帮我理解 理解呢。。 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|