{"id":678,"date":"2015-05-26T14:50:14","date_gmt":"2015-05-26T12:50:14","guid":{"rendered":"https:\/\/www.livediesel.de\/?p=678"},"modified":"2015-05-26T15:00:21","modified_gmt":"2015-05-26T13:00:21","slug":"msp432-interrupt-system","status":"publish","type":"post","link":"https:\/\/www.livediesel.de\/?p=678","title":{"rendered":"MSP432\u2122 Interrupt system"},"content":{"rendered":"<p>The MSP432\u2122 uses a additional level for interrupts: the\u00a0Nested Vectored Interrupt Controller (NVIC). Every interrupt you request must be enabled in the NVIC.<\/p>\n<p>To enable for example the Timer_A0_N interrupt you have to call also the NVIC function:<\/p>\n<pre>NVIC_EnableIRQ(TA0_N_IRQn);\r\n<\/pre>\n<p>You can see a list of all interrupts in the\u00a0msp432p401r.h file, there is a enum type\u00a0IRQn_Type.<\/p>\n<p>At next you can choose between Code based and RAM based interrupt vectors.<\/p>\n<h3>Code based interrupt<\/h3>\n<p>The Code based interrupts are hardlinked between the IVT and the ISR.<\/p>\n<p>To put a ISR in the IVT you have define the ISR in your application first:<\/p>\n<pre lang=\"c\">\/\/ ISR for Timer_A0_N\r\nvoid Timer_A0_N (void)\r\n{\r\n\t\/\/ handle IRQ\r\n}\r\n<\/pre>\n<p>At default the IVT is defined in the\u00a0msp432_startup_ccs.c file, there you have to declare your function:<\/p>\n<pre lang=\"c\">\/* External declarations for the interrupt handlers used by the application. *\/\r\n\/* To be added by user *\/\r\nextern void Timer_A0_N (void);\r\n<\/pre>\n<p>At last you assign the function to the IVT:<\/p>\n<pre lang=\"c\">#pragma DATA_SECTION(interruptVectors, \".intvecs\")\r\nvoid (* const interruptVectors[])(void) =\r\n{\r\n\t(void (*)(void))((uint32_t)&amp;__STACK_END),\r\n\t...\r\n\tTimer_A0_N,                             \/* TA0_N ISR                 *\/\r\n\t...\r\n};\r\n<\/pre>\n<p>In the document\u00a0<strong><a href=\"http:\/\/www.ti.com\/lit\/pdf\/slaa656\" target=\"_blank\">SLAA656<\/a><\/strong>\u00a0(MSP432\u2122 Platform Porting Guide) version <strong>2015-03<\/strong>\u00a0is witten the old &#8222;#pragma vector&#8220; method should also work, but at my tests the compiler thows some errors on it.<\/p>\n<h3>RAM based interrupt<\/h3>\n<p>RAM based interrupts can be used in oder if you have multiple applications running on your MSP and every application has it&#8217;s own ISRs.<\/p>\n<p>For the use of RAM based interrupts I\u00a0recommend to use the\u00a0<strong><a href=\"http:\/\/www.ti.com\/tool\/mspdriverlib\" target=\"_blank\">MSP432 DriverLib<\/a> Interrupt API<\/strong>. You have to create a RAM table and manage the IV entrys and the API is straight forward and implements all the needed functions.<\/p>\n<p>You can start using Code based interrupts, if you call the\u00a0Interrupt_registerInterrupt function at first time, it will copy the whole IVT from Code to RAM.<\/p>\n<p>The Interrupt_registerInterrupt and\u00a0Interrupt_unregisterInterrupt does not enable or disable the interrupt, you have to call\u00a0Interrupt_enableInterrupt and\u00a0Interrupt_disableInterrupt manually.<\/p>\n<p>As example the timer\u00a0interrupt:<\/p>\n<pre lang=\"c\">\/\/ from MSP432 DriverLib\r\n#include \"interrupt.h\"\r\n\r\n\/\/ ISR for Timer_A0_N\r\nvoid Timer_A0_N (void)\r\n{\r\n\t\/\/ handle IRQ\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\t...\r\n\tInterrupt_registerInterrupt(INT_TA0_N, Timer_A0_N);\r\n\tInterrupt_enableInterrupt(INT_TA0_N);\r\n\t...\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The MSP432\u2122 uses a additional level for interrupts: the\u00a0Nested Vectored Interrupt Controller (NVIC). Every interrupt you request must be enabled in the NVIC. To enable for example the Timer_A0_N interrupt you have to call also the NVIC function: NVIC_EnableIRQ(TA0_N_IRQn); You can see a list of all interrupts in the\u00a0msp432p401r.h file, there is a enum type\u00a0IRQn_Type. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,64],"tags":[68,66,52,65,67,51],"class_list":["post-678","post","type-post","status-publish","format-standard","hentry","category-mikrocontroller","category-msp432","tag-interrupt","tag-lauchpad","tag-msp","tag-msp432","tag-msp432p401r","tag-ti"],"_links":{"self":[{"href":"https:\/\/www.livediesel.de\/index.php?rest_route=\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.livediesel.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.livediesel.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.livediesel.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.livediesel.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":13,"href":"https:\/\/www.livediesel.de\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":693,"href":"https:\/\/www.livediesel.de\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions\/693"}],"wp:attachment":[{"href":"https:\/\/www.livediesel.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.livediesel.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.livediesel.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}