Microchip | The Embedded Control Solutions Company Register Login
Browse All
Microchip Technology
 305 Code Snippets

CE006 - Address Error Traps for Easy Debugging

Microchip Technology

The code example in the "address_error_trap.s" file demonstrates a simple means by which the user may detect the location of the instruction that causes an address error trap to occur. You may add this file to your project to ease debugging during development of your application. The code in the "main.s" file simply performs an illegal MOV instruction so as to cause an Address Error Trap.

About this Code Example

Microchip's 16-bit dsPIC® Digital Signal Controllers feature an on-chip mechanism to detect software errors and take corrective action. Specifically, the ability to detect memory addressing errors is provided by means of automatic Address Error Trap detection. Memory addressing errors may be caused by one of the following:

a. A misaligned data word fetch is attempted. This condition occurs when an instruction performs a word access with the LSb of the effective address set to ‘1’. The dsPIC30F CPU requires all word accesses to be aligned to an even address boundary.

b. A bit manipulation instruction using the Indirect Addressing mode with the LSb of the effective address set to ‘1’.

c. A data fetch from unimplemented data address space is attempted.

d. Execution of a “BRA #literal” instruction or a “GOTO #literal” instruction, where literal is an unimplemented program memory address.

e. Executing instructions after modifying the PC to point to unimplemented program memory addresses. The PC may be modified by loading a value into the stack and executing a RETURN instruction.

If the application defines an Address Error Trap service routine (trap handler), the processor will vector to the trap handler when it detects an Address Error trap.

The attached code example contains two assembler files. The code example in the "address_error_trap.s" file demonstrates a simple means by which the user may detect the location of the instruction that causes an address error trap to occur.  You may add this file to your project to ease debugging during development of your application. The code in the "main.s" file simply performs an illegal MOV instruction so as to cause an Address Error Trap.

Categories

Release History

  • Jun 22, 2012

    Version: 1.0.0

    First Release to ECS

Download Contact the Developer

*Required Fields

  • Current Version:1.0.0
  • Created:Jun 23, 2012
  • Updated:Feb 26, 2015
  • Downloads:3862
  • MPLAB Version:V8.xx or above
  • C Compiler:MCC18 v3.30 or above
  • Development Tools:dsPICDEMâ„¢ 1.1 Development Board
  • Supported Devices:dsPIC30F6014A

Corporate News

Resources

Stay Connected

Stay up to date with the latest news from Microchip Technology.