初级会员

- 积分
- 172
- 金钱
- 172
- 注册时间
- 2014-12-26
- 在线时间
- 120 小时
|
10金钱
最近在调试CLRC663程序时,把程序从stm32f1移植到stm32f0遇到一个问题:发生hard fault错误!这是很少遇见的错误呀!最后定位在一句代码:*ppRxBuffer = pDataParams->pRxBuffer;注释掉这句代码就不会产生hard fault。
这句代码在stm32f1上没问题,但在tm32f0上有问题。
相关定义:
#pragma pack(4)
uint8_t ** ppData = (uint8_t**)&pData[0];
#pragma pack()
ppData是ppRxBuffer的实参。
#pragma pack(4)
typedef struct
{
uint16_t wId; /**< Layer ID for this component, NEVER MODIFY! */
void * pBalDataParams; /**< Pointer to the lower layers parameter structure. */
uint8_t bLoadRegMode; /**< Whether LoadReg-Mode is enabled or not. */
uint8_t * pLoadRegConfig; /**< Pointer to configuration buffer for LoadReg mode; Refer to \ref phhalHw_Rc663_Init. */
uint8_t * pTxBuffer; /**< Pointer to global transmit buffer used by the Exchange() function. */
uint16_t wTxBufSize; /**< Size of the global transmit buffer. */
uint16_t wTxBufLen; /**< Number of valid bytes within the transmit buffer. */
uint8_t * pRxBuffer; /**< Pointer to global receive buffer used by the Exchange() function. */
uint16_t wRxBufSize; /**< Size of the global receive buffer. */
uint16_t wRxBufLen; /**< Number of valid bytes within the receive buffer. */
uint16_t wRxBufStartPos; /**< Starting position within the global receive buffer. */
uint16_t wMaxPrecachedBytes; /**< Holds the max. number of bytes which are precached prior to command execution. */
uint8_t bCardType; /**< Type of card for which the hal is configured for. */
uint16_t wCfgShadow[PHHAL_HW_RC663_SHADOW_COUNT]; /**< Configuration shadow; Stores configuration for current cardtype. */
uint16_t wTimingMode; /**< Current timing measurement mode. */
uint8_t bTimeoutUnit; /**< Unit of current timeout value (either #PHHAL_HW_TIME_MICROSECONDS or #PHHAL_HW_TIME_MILLISECONDS). */
uint32_t dwTimingUs; /**< Current timing value. */
uint16_t wFieldOffTime; /**< Field-Off-Time in milliseconds. */
uint16_t wFieldRecoveryTime; /**< Field-Recovery-Time in milliseconds. */
uint8_t bSymbolStart; /**< Preamble of a frame. */
uint8_t bSymbolEnd; /**< Trailer symbol of a frame. */
uint8_t bFifoSize; /**< Fifo-Size setting. */
uint16_t wAdditionalInfo; /**< Storage for additional error information. */
uint8_t bBalConnectionType; /**< Type of the underlying BAL connection. Refer to #PHHAL_HW_CONFIG_BAL_CONNECTION. */
uint8_t bRfResetAfterTo; /**< Storage for #PHHAL_HW_CONFIG_RFRESET_ON_TIMEOUT setting. */
} phhalHw_Rc663_DataParams_t;
#pragma pack()
pRxBuffer是以上结构体的一个元素。
查了网上资料,有可能是非对称内存读取,就是stm32f0只能从偶数地址读取数据,不能从奇数地址读取数据,否则引发hard fault。可是已经设定字节对齐了啊。
请教各位大神,这是什么问题?怎么才能避免?
|
最佳答案
查看完整内容[请看2#楼]
u8指针就不存在对齐的问题, 在watch看看ppRxBuffer的值, 问题在它身上。有可能是ppRxBuffer的值是指向F1有的内存块而F0是没有的
|