This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debug is getting stuck at "BKPT 0XAB"

Hi. I'm a newbie coding for an STM32F4 Discovery board. I'm working with some modified sample code and when I try to debug it, I'm getting stuck at "BKPT 0XAB", and I can't progress any further.

Can someone help me understand what causes this and how I can fix it?

Parents
  • You're probably using printf or putchar without providing any code to "retarget" that functionality to your board/processor. Adapt as required

    C:\Keil474\ARM\Boards\ST\STM3240G-EVAL\Blinky\Retarget.c

    /*----------------------------------------------------------------------------
     * Name:    Retarget.c
     * Purpose: 'Retarget' layer for target-dependent low level functions
     * Note(s):
     *----------------------------------------------------------------------------
     * This file is part of the uVision/ARM development tools.
     * This software may only be used under the terms of a valid, current,
     * end user licence from KEIL for a compatible version of KEIL software
     * development tools. Nothing else gives you the right to use this software.
     *
     * This software is supplied "AS IS" without warranties of any kind.
     *
     * Copyright (c) 2011 Keil - An ARM Company. All rights reserved.
     *----------------------------------------------------------------------------*/
    
    #include <stdio.h>
    #include <rt_misc.h>
    #include "Serial.h"
    
    #pragma import(__use_no_semihosting_swi)
    
    
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    
    int fputc(int c, FILE *f) {
      return (SER_PutChar(c));
    }
    
    
    int fgetc(FILE *f) {
      return (SER_GetChar());
    }
    
    
    int ferror(FILE *f) {
      /* Your implementation of ferror */
      return EOF;
    }
    
    
    void _ttywrch(int c) {
      SER_PutChar(c);
    }
    
    
    void _sys_exit(int return_code) {
    label:  goto label;  /* endless loop */
    }
    

    C:\Keil474\ARM\Boards\ST\STM3240G-EVAL\Blinky\Serial.c

    /*----------------------------------------------------------------------------
     * Name:    Serial.c
     * Purpose: Low level serial routines
     * Note(s):
     *----------------------------------------------------------------------------
     * This file is part of the uVision/ARM development tools.
     * This software may only be used under the terms of a valid, current,
     * end user licence from KEIL for a compatible version of KEIL software
     * development tools. Nothing else gives you the right to use this software.
     *
     * This software is supplied "AS IS" without warranties of any kind.
     *
     * Copyright (c) 2004-2011 Keil - An ARM Company. All rights reserved.
     *----------------------------------------------------------------------------*/
    
    #include <stm32f4xx.h>                  /* STM32F4xx Definitions              */
    #include "Serial.h"
    
    #ifdef __DBG_ITM
    volatile int32_t ITM_RxBuffer;
    #endif
    
    /*-----------------------------------------------------------------------------
     *       SER_Init:  Initialize Serial Interface
     *----------------------------------------------------------------------------*/
    void SER_Init (void) {
    #ifdef __DBG_ITM
      ITM_RxBuffer = ITM_RXBUFFER_EMPTY;
    
    #else
      RCC->APB1ENR  |= (1UL << 19);         /* Enable USART4 clock                */
      RCC->APB2ENR  |= (1UL <<  0);         /* Enable AFIO clock                  */
      RCC->AHB1ENR  |= (1UL <<  2);         /* Enable GPIOC clock                 */
    
      GPIOC->MODER  &= 0xFF0FFFFF;
      GPIOC->MODER  |= 0x00A00000;
      GPIOC->AFR[1] |= 0x00008800;          /* PC10 UART4_Tx, PC11 UART4_Rx (AF8) */
    
      /* Configure UART4: 115200 baud @ 42MHz, 8 bits, 1 stop bit, no parity      */
      UART4->BRR = (22 << 4) | 12;
      UART4->CR3 = 0x0000;
      UART4->CR2 = 0x0000;
      UART4->CR1 = 0x200C;
    #endif
    }
    
    
    /*-----------------------------------------------------------------------------
     *       SER_PutChar:  Write a character to Serial Port
     *----------------------------------------------------------------------------*/
    int32_t SER_PutChar (int32_t ch) {
    #ifdef __DBG_ITM
      int i;
      ITM_SendChar (ch & 0xFF);
      for (i = 10000; i; i--);
    #else
      while (!(UART4->SR & 0x0080));
      UART4->DR = (ch & 0xFF);
    #endif
    
      return (ch);
    }
    
    
    /*-----------------------------------------------------------------------------
     *       SER_GetChar:  Read a character from Serial Port
     *----------------------------------------------------------------------------*/
    int32_t SER_GetChar (void) {
    #ifdef __DBG_ITM
      if (ITM_CheckChar())
        return ITM_ReceiveChar();
    #else
      if (UART4->SR & 0x0020)
        return (UART4->DR);
    #endif
      return (-1);
    }
    
    /*-----------------------------------------------------------------------------
     * end of file
     *----------------------------------------------------------------------------*/
    

Reply
  • You're probably using printf or putchar without providing any code to "retarget" that functionality to your board/processor. Adapt as required

    C:\Keil474\ARM\Boards\ST\STM3240G-EVAL\Blinky\Retarget.c

    /*----------------------------------------------------------------------------
     * Name:    Retarget.c
     * Purpose: 'Retarget' layer for target-dependent low level functions
     * Note(s):
     *----------------------------------------------------------------------------
     * This file is part of the uVision/ARM development tools.
     * This software may only be used under the terms of a valid, current,
     * end user licence from KEIL for a compatible version of KEIL software
     * development tools. Nothing else gives you the right to use this software.
     *
     * This software is supplied "AS IS" without warranties of any kind.
     *
     * Copyright (c) 2011 Keil - An ARM Company. All rights reserved.
     *----------------------------------------------------------------------------*/
    
    #include <stdio.h>
    #include <rt_misc.h>
    #include "Serial.h"
    
    #pragma import(__use_no_semihosting_swi)
    
    
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    
    int fputc(int c, FILE *f) {
      return (SER_PutChar(c));
    }
    
    
    int fgetc(FILE *f) {
      return (SER_GetChar());
    }
    
    
    int ferror(FILE *f) {
      /* Your implementation of ferror */
      return EOF;
    }
    
    
    void _ttywrch(int c) {
      SER_PutChar(c);
    }
    
    
    void _sys_exit(int return_code) {
    label:  goto label;  /* endless loop */
    }
    

    C:\Keil474\ARM\Boards\ST\STM3240G-EVAL\Blinky\Serial.c

    /*----------------------------------------------------------------------------
     * Name:    Serial.c
     * Purpose: Low level serial routines
     * Note(s):
     *----------------------------------------------------------------------------
     * This file is part of the uVision/ARM development tools.
     * This software may only be used under the terms of a valid, current,
     * end user licence from KEIL for a compatible version of KEIL software
     * development tools. Nothing else gives you the right to use this software.
     *
     * This software is supplied "AS IS" without warranties of any kind.
     *
     * Copyright (c) 2004-2011 Keil - An ARM Company. All rights reserved.
     *----------------------------------------------------------------------------*/
    
    #include <stm32f4xx.h>                  /* STM32F4xx Definitions              */
    #include "Serial.h"
    
    #ifdef __DBG_ITM
    volatile int32_t ITM_RxBuffer;
    #endif
    
    /*-----------------------------------------------------------------------------
     *       SER_Init:  Initialize Serial Interface
     *----------------------------------------------------------------------------*/
    void SER_Init (void) {
    #ifdef __DBG_ITM
      ITM_RxBuffer = ITM_RXBUFFER_EMPTY;
    
    #else
      RCC->APB1ENR  |= (1UL << 19);         /* Enable USART4 clock                */
      RCC->APB2ENR  |= (1UL <<  0);         /* Enable AFIO clock                  */
      RCC->AHB1ENR  |= (1UL <<  2);         /* Enable GPIOC clock                 */
    
      GPIOC->MODER  &= 0xFF0FFFFF;
      GPIOC->MODER  |= 0x00A00000;
      GPIOC->AFR[1] |= 0x00008800;          /* PC10 UART4_Tx, PC11 UART4_Rx (AF8) */
    
      /* Configure UART4: 115200 baud @ 42MHz, 8 bits, 1 stop bit, no parity      */
      UART4->BRR = (22 << 4) | 12;
      UART4->CR3 = 0x0000;
      UART4->CR2 = 0x0000;
      UART4->CR1 = 0x200C;
    #endif
    }
    
    
    /*-----------------------------------------------------------------------------
     *       SER_PutChar:  Write a character to Serial Port
     *----------------------------------------------------------------------------*/
    int32_t SER_PutChar (int32_t ch) {
    #ifdef __DBG_ITM
      int i;
      ITM_SendChar (ch & 0xFF);
      for (i = 10000; i; i--);
    #else
      while (!(UART4->SR & 0x0080));
      UART4->DR = (ch & 0xFF);
    #endif
    
      return (ch);
    }
    
    
    /*-----------------------------------------------------------------------------
     *       SER_GetChar:  Read a character from Serial Port
     *----------------------------------------------------------------------------*/
    int32_t SER_GetChar (void) {
    #ifdef __DBG_ITM
      if (ITM_CheckChar())
        return ITM_ReceiveChar();
    #else
      if (UART4->SR & 0x0020)
        return (UART4->DR);
    #endif
      return (-1);
    }
    
    /*-----------------------------------------------------------------------------
     * end of file
     *----------------------------------------------------------------------------*/
    

Children