<?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>Kinetis Microcontrollers中的主题 Codewarrior Interrupt Example with Proper Clock Init</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Codewarrior-Interrupt-Example-with-Proper-Clock-Init/m-p/187659#M2066</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This example shows how to use interrupts within CodeWarrior 10.1 on the kinetis K40 tower board.&amp;nbsp;&amp;nbsp; Since there are no examples of how to do this yet on the Freescale website, I thought I would put this together for the rest of the world.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example will blink LEDs E1,E2 and E3 at different rates using a combination of a SysTick Interrupt, a Flex Timer Overflow interrupt and a delay function that uses the SysTick interrupt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The MCG is setup to use the external clock for the PLL with a target core frequency of 96MHz.&amp;nbsp; Note that this code shows how to place the clock init stuff in RAM per the errata e2448 so you can properly execute from FLASH!&amp;nbsp;&amp;nbsp; Also, the Device initialization wizard generates bad code!&amp;nbsp; It will generate a fault exception.&amp;nbsp;&amp;nbsp; This code is from the &lt;STRONG&gt;Kinetis Peripheral Module Quick Reference&lt;/STRONG&gt; and works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I setup the Cortex System Tick Timer (documented in the generic Cortex M4 Generic User Guide as it is part of every cortex M4: &lt;A href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/index.html" rel="nofollow" target="_blank"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/index.html&lt;/A&gt;) to interrupt at a 10mS rate.&amp;nbsp; The System Tick DOES NOT go through the NVIC.&amp;nbsp; All you have to do is hit a couple registers to set it up and place the IRQ service routine in the function pointer table in kinetis_sysinit.c&amp;nbsp;&amp;nbsp; Inside my irq routine, I toggle LED_E1 every 250mS.&amp;nbsp;&amp;nbsp; I also increment a generic counter that is used for a delay routine in the main() loop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I setup the Flex Timer 0 for overflow interrupts at a rate of 10mS.&amp;nbsp;&amp;nbsp; Since the FlexTimer is a Freescale peripheral,&amp;nbsp; its interrupts go through the NVIC.&amp;nbsp;&amp;nbsp; You must enable interrupts in the module, then the NVIC registers (documented in the generic Cortex user guide).&amp;nbsp;&amp;nbsp; Arm_cm4.c has some useful functions for enabling an interrupt on the NVIC.&amp;nbsp; Hopefully someday Freescale will support CMSIS!&amp;nbsp;&amp;nbsp; Page 72 – 75 has the NVIC irq/vector assignments.&amp;nbsp; The IRQ# is used for the NVIC registers (the enable_irq() function) and the vector # is used for the table entry in kinetis_sysinit.c.&amp;nbsp; Note that they are not the same as the first 16 vectors are reserved for the Cortex core standard exceptions.&amp;nbsp;&amp;nbsp; Vectors for a specific chip start after #16.&amp;nbsp; Once you enable the interrupt for an module, enable the NVIC channel, and then populate the vector table,&amp;nbsp; interrupts should just work.&amp;nbsp; Note that assembly language instruction to enable all interrupts&amp;nbsp; (CPSIE i) is already done for you in the start up routines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Mar 2011 21:23:17 GMT</pubDate>
    <dc:creator>emh203</dc:creator>
    <dc:date>2011-03-02T21:23:17Z</dc:date>
    <item>
      <title>Codewarrior Interrupt Example with Proper Clock Init</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Codewarrior-Interrupt-Example-with-Proper-Clock-Init/m-p/187659#M2066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This example shows how to use interrupts within CodeWarrior 10.1 on the kinetis K40 tower board.&amp;nbsp;&amp;nbsp; Since there are no examples of how to do this yet on the Freescale website, I thought I would put this together for the rest of the world.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example will blink LEDs E1,E2 and E3 at different rates using a combination of a SysTick Interrupt, a Flex Timer Overflow interrupt and a delay function that uses the SysTick interrupt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The MCG is setup to use the external clock for the PLL with a target core frequency of 96MHz.&amp;nbsp; Note that this code shows how to place the clock init stuff in RAM per the errata e2448 so you can properly execute from FLASH!&amp;nbsp;&amp;nbsp; Also, the Device initialization wizard generates bad code!&amp;nbsp; It will generate a fault exception.&amp;nbsp;&amp;nbsp; This code is from the &lt;STRONG&gt;Kinetis Peripheral Module Quick Reference&lt;/STRONG&gt; and works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I setup the Cortex System Tick Timer (documented in the generic Cortex M4 Generic User Guide as it is part of every cortex M4: &lt;A href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/index.html" rel="nofollow" target="_blank"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/index.html&lt;/A&gt;) to interrupt at a 10mS rate.&amp;nbsp; The System Tick DOES NOT go through the NVIC.&amp;nbsp; All you have to do is hit a couple registers to set it up and place the IRQ service routine in the function pointer table in kinetis_sysinit.c&amp;nbsp;&amp;nbsp; Inside my irq routine, I toggle LED_E1 every 250mS.&amp;nbsp;&amp;nbsp; I also increment a generic counter that is used for a delay routine in the main() loop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I setup the Flex Timer 0 for overflow interrupts at a rate of 10mS.&amp;nbsp;&amp;nbsp; Since the FlexTimer is a Freescale peripheral,&amp;nbsp; its interrupts go through the NVIC.&amp;nbsp;&amp;nbsp; You must enable interrupts in the module, then the NVIC registers (documented in the generic Cortex user guide).&amp;nbsp;&amp;nbsp; Arm_cm4.c has some useful functions for enabling an interrupt on the NVIC.&amp;nbsp; Hopefully someday Freescale will support CMSIS!&amp;nbsp;&amp;nbsp; Page 72 – 75 has the NVIC irq/vector assignments.&amp;nbsp; The IRQ# is used for the NVIC registers (the enable_irq() function) and the vector # is used for the table entry in kinetis_sysinit.c.&amp;nbsp; Note that they are not the same as the first 16 vectors are reserved for the Cortex core standard exceptions.&amp;nbsp;&amp;nbsp; Vectors for a specific chip start after #16.&amp;nbsp; Once you enable the interrupt for an module, enable the NVIC channel, and then populate the vector table,&amp;nbsp; interrupts should just work.&amp;nbsp; Note that assembly language instruction to enable all interrupts&amp;nbsp; (CPSIE i) is already done for you in the start up routines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 21:23:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Codewarrior-Interrupt-Example-with-Proper-Clock-Init/m-p/187659#M2066</guid>
      <dc:creator>emh203</dc:creator>
      <dc:date>2011-03-02T21:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior Interrupt Example with Proper Clock Init</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Codewarrior-Interrupt-Example-with-Proper-Clock-Init/m-p/187660#M2067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot for this... Got my TOWER K60 up and running thanks to this code.&lt;/P&gt;&lt;P&gt;The documentation for the Kinetis needs a good reference manual explaining all the nitty gritty. For other Freescale products the documentation is way better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Apr 2011 15:33:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Codewarrior-Interrupt-Example-with-Proper-Clock-Init/m-p/187660#M2067</guid>
      <dc:creator>JTech</dc:creator>
      <dc:date>2011-04-01T15:33:30Z</dc:date>
    </item>
  </channel>
</rss>

