2013-04-11 01:52 AM
void DMA2_Stream2_Rx(void)
{ USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); USART_ITConfig(USART1,USART_IT_ORE_RX,ENABLE); USART_DMACmd(USART1,USART_DMAReq_Rx,DISABLE); memcpy(&mbdCurRxDNode->c->rxBuf[1], &stm32f4_mbus_drv_rx_buf[1],7); STM32F4_ENDRX_RxInt(); } This is the DMA interrupter function,when the program excutes memcpy function,the HardFault Hander occurs. The destination buffer and the source buffer are global!2013-04-11 02:34 AM
memcpy(&mbdCurRxDNode->c->rxBuf[
1
], &stm32f4_mbus_drv_rx_buf[1
],7);In C, arrays ALWAYS start at index 0. So your memcpy() parameters are very likely to be odd addresses, which is only supported by certain instructions.(
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/BABFAIGG.html
) And the library code for memcpy() may not use them (assuming you have picked the correct library at all). Why use clib at all ? A simple for loop might do as well.2013-04-11 02:36 AM
And it just occurs when booting from flash!
Can anybody resolve this issue? Thanks2013-04-11 02:41 AM
And I use a ''for'' loop to do the copy, but the Hardfualt still occurs.
2013-04-11 03:00 AM
Did you check that your address parameters point to the actual addresses upon entering memcpy ?
memcpy(&mbdCurRxDNode->c->rxBuf[1], &stm32f4_mbus_drv_rx_buf[1],7);I find the suspicious. Adding braces could help to explain what you mean. &mbdCurRxDNode->c->rxBuf[1], -> &
(
mbdCurRxDNode->c->rxBuf[1])
2013-04-11 04:41 AM
One, or both addresses are bad, determine which, determine why.
2013-04-11 05:16 AM
I checked the address when Hardfault occurs. The destinaton buffer address(mbdCurRxDNode->c->rxBuf[0]) is 0x01478048 and it is not an effective memory address.
But I don't know why.2013-04-11 06:51 AM
Your job will be to figure that out, one of the structures/unions along that chain (pointers to pointers) has bogus content. Understand how the structures in the chain were built and filled.