Question

How do i disable the interrupt in this ARM M0 univesity design start program? The design is made for the M0 and echos an inputted char as an integer, it is part of a larger piece of code (which is ommitted for simplicity) Can i do it in the main program(attached) or will i have to edit the assembler code(also attached)?

  //------------------------------------------------------------------------------
// Cortex-M0 DesignStart C program example
//------------------------------------------------------------------------------

#include <stdio.h>
#include <time.h>
#include <rt_misc.h>
#include <stdlib.h>

#define AHB_LED_BASE                0x50000000
#define AHB_UART_BASE               0x51000000


void UART_ISR(void)
{
            int sample;
            char ch [16];
            sample = atoi (ch);
            printf("the value entered is %d\n", sample);
}

//////////////////////////////////////////////////////////////////
// Main Function
//////////////////////////////////////////////////////////////////

int main() 
    {

        char ch [16];
        while(1==1)
        {
        fgets (ch, 16, stdin);
    //printf("String: %s\n\n",ch);
        }
}

Assembly code

UART_Handler    PROC
                EXPORT UART_Handler
                IMPORT UART_ISR
                PUSH    {R0,R1,R2,LR}
                LDR     R1, =0x51000000               ;UART
                LDR     R0, [R1]                      ;Get Data from UART
                STR     R0, [R1]                      ;Write to UART

                BL UART_ISR

                POP     {R0,R1,R2,PC}
                ENDP


                ALIGN 4
Was it helpful?

Solution

If you use CMSIS drivers, check for:

  1. void __disable_irq(void)
  2. void __enable_irq(void)

They just call CPSIE and CPSID instructions.

Generally read about NVIC in the programming manual. I also recommend a fantastic book on Cortex M0:

The Definitive Guide to the ARM Cortex-M0 by Joseph Yiu.

OTHER TIPS

If u wish to write a simple code in ASM, you can simply store and raise the BASEPRI to a higher priority than all the NVIC's (besides, say, exception type debugMon), do what u need todo and than restore the original BASEPRI

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top