Skip to main content
jamessteward
Associate II
January 20, 2009
Question

HardFault accessing variables in ISR

  • January 20, 2009
  • 2 replies
  • 584 views
Posted on January 21, 2009 at 00:08

HardFault accessing variables in ISR

    This topic has been closed for replies.

    2 replies

    jamessteward
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:00

    I'll answer for me....I believe I simply ran out of RAM!

    jamessteward
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:00

    Hi,

    I'm playing with an STM32-P103 from Olimex. I started with the ADC DMA example 1, ported it to the target board and removed the SPI functions (not needed for me).

    I have a structure;

    typedef struct {

    u16 dma_buf[ADC_BLEN];

    u16 pipe[ADC_PIPE];

    u16 head, tail;

    u16 status;

    u32 int_rms, rms;

    } adc_t;

    in main.h, and declare a variable

    adc_t adc;

    in main.c, and as

    extern adc_t adc;

    in stm32f10x_it.c.

    main.c has the needed stuff in the DMA setup I think..

    DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;

    DMA_InitStructure.DMA_MemoryBaseAddr = (u32) &(adc.dma_buf);

    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;

    DMA_InitStructure.DMA_BufferSize = ADC_BLEN;

    Now, if I set ADC_BLEN to 512, it runs. If I set to 1024, I get a HardFault.

    I removed all references to the variable 'adc' from the DMA ISR, and still the same.

    I'm building with CodeSourcery tools, and it compiles and links cleanly with -Wall.

    Is there some problem, or limitation, WRT defining the buffer for DMA?

    Regards,

    James.