<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>S12 / MagniV Microcontrollers中的主题 Re: HCS12 Interrupts (bootloader and main firmware)</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624854#M13378</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Radek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, __interrupt is fine as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JMP  is also right. It takes vector at DF88 and jumps where it points to. (BTW  #adr denotes immediate addressing as opposed to extended adr. There’s no immediate addressing choice for JMP, only extended).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps linker optimized application vectors table out? Simulator or debugger should help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Apr 2017 09:47:13 GMT</pubDate>
    <dc:creator>kef2</dc:creator>
    <dc:date>2017-04-20T09:47:13Z</dc:date>
    <item>
      <title>HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624851#M13375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. Sorry for my poor English.&lt;BR /&gt;I'm using 9s12e64 MCU and trying to write my own bootloader (it does not use interrupts) IDE CW5.1 + processor expert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bootoader placed at address 0xe000-0xffff. Secondary interrupt table placed at 0xdf80-0xdfff Bootloader works fine, gets firmware, jumps to main application. Main app works. But there is on issue: I can't use interrupts in my main application.&amp;nbsp;when interrupt occurs, MCU "hangs" (LED stops blinking) I've read AN2153, looked through AN2153SW and &lt;A href="https://community.nxp.com/thread/10262"&gt;CW &amp;amp;amp; HC12D60A VECTOR RELOCATION&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;Here is some pieces of my code, where can be mistake:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Events.c (bootloader)&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;/P&gt;&lt;P&gt;void extVpwmesdn (void) { asm JMP [0xDF88,pcr]; } &lt;BR /&gt;void extVvreglvi (void) { asm JMP [0xDF8A,pcr]; } &lt;BR /&gt;....&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Vectors.c (bootloader)&lt;/P&gt;&lt;P&gt;static const tIsrFunc _InterruptVectorTable[] @0xFF80U = { /* Interrupt vector table */&lt;BR /&gt;/*lint -restore Enable MISRA rule (1.1) checking. */&lt;BR /&gt; /* ISR name No. Address Pri Name Description */&lt;BR /&gt; &amp;amp;Cpu_Interrupt, /* 0x3F 0xFF80 1 ivVReserved63 unused by PE */&lt;BR /&gt;....&lt;BR /&gt; &amp;amp;extVpwmesdn, /* 0x3B 0xFF88 1 ivVpwmesdn used by PE */&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// interrupt, that does not works properly in main app:&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;ISR(FC1_Interrupt)&lt;BR /&gt;{&lt;BR /&gt; TIM2_TFLG1 = 0x80U; /* Reset interrupt request flag */&lt;BR /&gt; FC1_OnInterrupt(); /* Invoke user event */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG FC1_CODE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached screenshots of PE CPU settings for main app&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Apr 2017 10:27:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624851#M13375</guid>
      <dc:creator>viacheslavbala1</dc:creator>
      <dc:date>2017-04-19T10:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624852#M13376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;#pragma TRAP_PROC is missing, which would make your ISR exit with RTI instruction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;#pragma TRAP_PROC&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;ISR(FC1_Interrupt)&lt;BR /&gt;{&lt;BR /&gt; TIM2_TFLG1 = 0x80U; /* Reset interrupt request flag */&lt;BR /&gt; FC1_OnInterrupt(); /* Invoke user event */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG FC1_CODE&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 08:04:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624852#M13376</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-20T08:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624853#M13377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Viacheslav,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The old S12 devices, unfortunately, do not contains IVBR register for shifting vector base address.&lt;/P&gt;&lt;P&gt;I suppose that I understood to your construction, but I am not exactly sure why it do not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main problem is that application interrupt vector table belongs to flash occupied by the bootloader.&lt;/P&gt;&lt;P&gt;Your implementation contains ISRs in bootloader code with simple jumps per application vector table.&lt;/P&gt;&lt;P&gt;I am not sure with your jump command like &lt;EM&gt;asm JMP [0xDF88,pcr];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This command use indexed addressing.&lt;/P&gt;&lt;P&gt;I suppose, that when address 0xDF88 contains directly vector to application ISR, you should use extended addressing like &lt;EM&gt;asm JMP #DF88;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The JMP opcode for extended addressing is 0x06 and 0x05 for indexed addressing. Please check generated extVpwmesdn() code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edward,&lt;/P&gt;&lt;P&gt;The PE defines ISR() as &lt;EM&gt;#define ISR(x) __interrupt void x(void)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;So, &lt;EM&gt;#pragma TRAP_PROC&lt;/EM&gt; should not be necessary. The interrupt keyword is used instead of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 09:01:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624853#M13377</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2017-04-20T09:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624854#M13378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Radek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, __interrupt is fine as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JMP  is also right. It takes vector at DF88 and jumps where it points to. (BTW  #adr denotes immediate addressing as opposed to extended adr. There’s no immediate addressing choice for JMP, only extended).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps linker optimized application vectors table out? Simulator or debugger should help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 09:47:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624854#M13378</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-20T09:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624855#M13379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Edward,&lt;/P&gt;&lt;P&gt;You are right with JMP address. My fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About optimization)&lt;/P&gt;&lt;P&gt;good point. It might be next potential root cause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Viacheslav,&lt;/P&gt;&lt;P&gt;Linker optimize out nonreferenced constants as unused. Please check generated map file in bootloader and application projects.&lt;/P&gt;&lt;P&gt;You may place constant name into ENTRIES section in prm linker file for avoiding that optimization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 11:18:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624855#M13379</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2017-04-20T11:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624856#M13380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank everyone&amp;nbsp;for replies.&lt;/P&gt;&lt;P&gt;vector table placed in .s19 file at&amp;nbsp;necessary address (starts at 0xdf80, ends at 0xdfff). It is also present in *.map file.&lt;/P&gt;&lt;P&gt;main app works fine without bootloader (if I placed interrupts to 0xff80). In this case *.s19 file is not changed (only vector table address). So my mistake probably somewhere in bootloader. The worst thing: assembler language is some kind of magic for me :smileyhappy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;may be I have to attach my bootloader project?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="main_app_abs_and_map.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/11435i706A2C04DF6619BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="main_app_abs_and_map.png" alt="main_app_abs_and_map.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 12:14:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624856#M13380</guid>
      <dc:creator>viacheslavbala1</dc:creator>
      <dc:date>2017-04-20T12:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624857#M13381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Viacheslav,&lt;/P&gt;&lt;P&gt;Thank you for your check.&lt;/P&gt;&lt;P&gt;My personal experiences with assembler programming are also limited.&lt;/P&gt;&lt;P&gt;Please try to replace &lt;EM&gt;asm JMP [0xDF88,pcr];&lt;/EM&gt; by &lt;EM&gt;asm JMP 0xDF88;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 12:27:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624857#M13381</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2017-04-20T12:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624858#M13382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Radek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JMP 0xDF88 will jump to routine at DF88. As I understand at DF88 should be vector table entry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 13:31:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624858#M13382</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-20T13:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624859#M13383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems you are jumping to a nonexistent memory location.&lt;/P&gt;&lt;P&gt;void extVpwmesdn (void) { asm JMP [0xDF88,pcr]; }&lt;/P&gt;&lt;P&gt;That instruction will add the value in pcr to 0xDF88 and use it as reference to get the address to jump to.&lt;/P&gt;&lt;P&gt;I believe that you need to use x or y index register and use them to get to the correct address.&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;void extVpwmesdn (void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm LDX #8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm JMP [0xDF80,x];&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;I am not familiar with this processor, but you get the idea, x should be the reference to the X index register.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Apr 2017 18:51:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624859#M13383</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-04-20T18:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624860#M13384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is pcr? It is not PC register, it‘s PC plus offset to compensate current instruction length, so that JMP  jumps to address stored at DF88. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 06:13:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624860#M13384</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-21T06:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624861#M13385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Edward,&lt;/P&gt;&lt;P&gt;You are right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested that approach in different situation – it was on S12Z and jump instruction was part of an application and not in the bootloader. That may be also some different type of workaround. The interface between bootloader and application will be just specific addresses where JMP instructions are located.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In application code something like:&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;/P&gt;&lt;P&gt;/* ISR prototype */&lt;/P&gt;&lt;P&gt;typedef void (* tIsrFunc)(void);&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; byte jmp_instruction;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tIsrFunc address;&lt;/P&gt;&lt;P&gt;} InterruptTableEntry;&lt;/P&gt;&lt;P&gt;#define _VECTOR(v) {0x06U, &amp;amp;v}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;InterruptTableEntry _InterruptVectorTable[INT_VECTOR_TABLE_SIZE] @INT_VECTOR_TABLE_ADDR_IN_FLASH = { /* Interrupt vector table */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _VECTOR(Unimplemented_ISR),//0x80&lt;/P&gt;&lt;P&gt;//…&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //_VECTOR(Unimplemented_ISR),//&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _VECTOR(API_ISR),//0x100&lt;/P&gt;&lt;P&gt;//….&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _VECTOR(Unimplemented_ISR),//0x&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That should create a table with fields containing JMP instruction and direct address to the application ISRs. The complication and advantage simultaneously are that calculating addresses for bootloader vector are not so straightforward (3 bytes per record). The advantage is that this vector table may be placed anywhere in nonbanked flash and order or number of implemented ISR records is also not limited (you may skip Reserved or unused interrupts) since it is not referenced by interrupt hardware directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In extreme case, this may be also done directly in linker file. Example for one interrupt vector.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM_JMP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = READ_ONLY&amp;nbsp;&amp;nbsp; 0xC000 TO 0xC000 FILL 0x06;&amp;nbsp; //asm JMP instruction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM_APP_VECTOR = READ_ONLY&amp;nbsp;&amp;nbsp; 0xC001 TO 0xC002;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //space for vector address - see VECTOR ADDRESS ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;ROM_C000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = READ_ONLY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xC003 TO&amp;nbsp;&amp;nbsp; 0xDF7F;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VECTOR ADDRESS 0xC001 API_ISR&lt;/P&gt;&lt;P&gt;The vector for API in bootloader should be filled by address 0xC000 in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 11:12:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624861#M13385</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2017-04-21T11:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624862#M13386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I said, I am not familiar with this processor. pcr is what the OP posted in his code which I assumed it was the PC, but I could be wrong&lt;/P&gt;&lt;P&gt;There is two JMP instructions with indexed-indirect addressing:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: small;"&gt;JMP [D&lt;/SPAN&gt;&lt;EM style="font-size: small; font-family: Arial;"&gt;,xysp&lt;/EM&gt;&lt;SPAN style="font-family: Arial; font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: Arial;"&gt;JMP [&lt;/SPAN&gt;&lt;EM style=": ; font-size: small; font-family: Arial;"&gt;oprx16,xysp&lt;/EM&gt;&lt;SPAN style="font-size: small; font-family: Arial;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: Arial;"&gt;according to the datasheet:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: Arial;"&gt;&lt;STRONG&gt;[&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;EM style=": ; font-size: small; font-family: Arial;"&gt;oprx16&lt;/EM&gt;&lt;STRONG style=": ; font-size: small; font-family: Arial;"&gt;,&lt;/STRONG&gt;&lt;EM style=": ; font-size: small; font-family: Arial;"&gt;xysp&lt;/EM&gt;&lt;STRONG style=": ; font-size: small; font-family: Arial;"&gt;]&lt;/STRONG&gt;&amp;nbsp;--- Pointer to operand is found at 16-bit constant offset from X, Y, SP, or PC(16-bit offset in two extension bytes), which means that for "JMP [0xDF88,pcr]; " you have pcr(PC?) + 0xDF88 as the location it gets address from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: Arial;"&gt;&lt;STRONG&gt;[D,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;EM style=": ; font-size: small; font-family: Arial;"&gt;xysp&lt;/EM&gt;&lt;STRONG style=": ; font-size: small; font-family: Arial;"&gt;]&lt;/STRONG&gt; --- Pointer to operand is found at X, Y, SP, or PC plus the value in D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 13:11:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624862#M13386</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-04-21T13:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624863#M13387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just realized that in instruction:&lt;/P&gt;&lt;P&gt;JMP [0xDF80,x];&lt;/P&gt;&lt;P&gt;0xDF80 is an offset. I don't know how the processor would handle it, but it may be a signed number to be able to offset forward and back, so you may need to use:&lt;/P&gt;&lt;P&gt;void extVpwmesdn (void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm LDX #0xDF80;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm JMP [8,x];&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 13:28:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624863#M13387</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-04-21T13:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624864#M13388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you are wrong. ,PC and ,pcr are different things. CW treats first as constant offset to PC, not taking into account instruction length, while second computes right offset to specified address and takes into account instruction length as well. Example, just try it in simulator or in real HW:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// routine to call&lt;/P&gt;&lt;P&gt;void near pcrcallee(void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; asm NOP&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// vector at 0xDF88&lt;/P&gt;&lt;P&gt;void (*near vect)(void) @ 0xDF88 = pcrcallee;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// right caller&lt;BR /&gt;void near caller(void){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; asm JMP [0xDF88,pcr]; &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// wrong caller&lt;/P&gt;&lt;P&gt;void near caller2(void){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; asm JMP [0xDF88,PC]; &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void main(void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; caller();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; caller2();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 13:45:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624864#M13388</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-21T13:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624865#M13389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand you correctly pcr is PC + instruction length and&amp;nbsp;this needs to be used to calculate offset correctly.&lt;/P&gt;&lt;P&gt;The instruction JMP [0xDF88, pcr] then offsets pcr by 0xDF88 which means the&amp;nbsp;address is relative.&lt;/P&gt;&lt;P&gt;However his vector is at absolute address 0xDF88 so it would be getting the address from the wrong location.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 13:58:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624865#M13389</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-04-21T13:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624866#M13390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, JMP  just jumps to vector at 0xDF88. Nothing wrong here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 20:06:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624866#M13390</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-21T20:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624867#M13391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh I see, I misunderstood your explanation. I checked in the manual and found the explanation somewhat hidden in the example for MIN and MAX instructions. Apparently they didn't think it was important enough to put it in the "Addressing Modes" or&amp;nbsp;"Instruction Set"&amp;nbsp;sections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The “,PCR” notation is also new for the CPU12. This notation indicates the&lt;/P&gt;&lt;P&gt;programmer wants an appropriate offset from the PC reference to the&lt;/P&gt;&lt;P&gt;memory location (HILIMIT or LOWLIMIT in this example), and then to&lt;/P&gt;&lt;P&gt;assemble this instruction into a PC-relative indexed MIN or MAX instruction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, using the JMP[address,pcr] notation makes the assembler/compiler calculate the offset and replace the instruction with a proper JMP[oprx16,PC] instruction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Apr 2017 20:24:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624867#M13391</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-04-21T20:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624868#M13392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Everyone. I think, my problem has been found.&lt;/P&gt;&lt;P&gt;When interrupt occurs, MCU serves interrupt in main firmware and hangs somewhere after RTI instruction.&lt;/P&gt;&lt;P&gt;So, some instruction corrupts stack. Here is disassembled code of interrupt in bootloader:&lt;/P&gt;&lt;P&gt;LDAA 0x30&lt;/P&gt;&lt;P&gt;PSHA&lt;/P&gt;&lt;P&gt;JMP [0xFF04, PC]&lt;/P&gt;&lt;P&gt;PULA&lt;/P&gt;&lt;P&gt;STAA 0x30&lt;/P&gt;&lt;P&gt;RTI&lt;/P&gt;&lt;P&gt;additional operations with stack - because of my compiler settings =)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all for the conversation.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Apr 2017 13:23:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624868#M13392</guid>
      <dc:creator>viacheslavbala1</dc:creator>
      <dc:date>2017-04-22T13:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 Interrupts (bootloader and main firmware)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624869#M13393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Slava,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;probably you enabled compiler option in bootloader Code Generation-&amp;gt;PPAGE register is used for paging (-CpPPAGE). When this is on, compiler saves/restores PPAGE on entry/exit form ISR. And this is what breaks your code. JMP doesn't return and PULA is never executed, stack destroyed. Either&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;disable that option. I guess you don't need it at all&lt;/LI&gt;&lt;LI&gt;Remove interrupt keyword from your bootloader ISR's. Since they only jump and never return, RTS instead of RTI at the end will be fine, but compiler won't push/pull PPAGE. &amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Apr 2017 20:13:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Interrupts-bootloader-and-main-firmware/m-p/624869#M13393</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2017-04-22T20:13:25Z</dc:date>
    </item>
  </channel>
</rss>

