How to trigger an interrupt from a debugger for testing?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need to test how my system responds to various interrupt nesting scenarios. Usually, I test this by triggering a specifically designed test interrupt at will from the debugger. This allows me to test scenarios that happen very infrequently.

My question is what is the easiest interrupt to use for such testing? How would you set it up and how would I trigger it from the debugger?

I've been experimenting with TC0, which was set up to compare after one tick. I tried writing 5 to TC0.CCR (at address 0xFFFF3800) to start the timer, but this does not trigger the interrupt and is also quite involved to set up.

I'd greatly appreciate any better recommendations. The exact device I'm using is AT32UC3A3256 (UC2-A3-Xplained board).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
// Enable compare register and pick clock 5 as input
AVR32_TC0.channel[0].cmr =
    (            TC_TRIGGER_COMPARE_RC << AVR32_TC_CMR0_CPCTRG_OFFSET ) |
    (AVR32_TC_CMR0_TCCLKS_TIMER_CLOCK5 << AVR32_TC_CMR0_TCCLKS_OFFSET );

// Set the compare counter to 1
AVR32_TC0.channel[0].rc = 1;

// Enable the compare interrupt
AVR32_TC0.channel[0].ier = AVR32_TC_IER0_CPCS_MASK;

// Enable clock and start counting
AVR32_TC0.channel[0].ccr =
    AVR32_TC_CCR0_SWTRG_MASK |
    AVR32_TC_CCR0_CLKEN_MASK;

//////////////////////////////////////////DearForumPleaseDontBreakMyLines

This should get you going with the TC.
Well, at least It Works For Me. ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot for the code. That's a much simpler setup than using ASF calls.

However, I still can't trigger the interrupt from the debugger. I commented out setting CCR to 5 (your last line) and wanted to write this 5 to CCR from the debugger, to trigger the interrupt at precisely the instruction I want to test. However, this does not work.

I'm using AtmelStudio 6. I've set up Memory window, baseIO, address 0xFFFF3800. I've set up the view at 4-byte integer, hexadecimal, Big Endian. Then I right-click on the 4-bytes at 0xFFFF3800 (TC0.CCR) and pick "Edit Value" from the pop-up menu. I then type 00000005 to the register. This reads back as all zeroes, because CCR is a write-only register. I've tried modifying a read/write register, such as CMR @0xFFFF3804 and it works (i.e. it reads back what I've modified).

But updates from the debugger to write-only registers don't seem to have any effect. Any help would be greatly appreciated.

How do you guys test your interrupt preemption scenarios? I mean, most interesting preemptions are almost impossible to test experimentally just waiting for things to happen...