
一段以前用的很多的程序,以前在别的工程用过很多了(stm32 M3系列, 51单片机) 今天拿到m0单片机的工程里一运行就hard fault 找来找去似乎是这么个问题: 用指针往一个地址里写长整数数据, 这个地址必须是4的整数倍? 类似这样: { int* a; int* b; a = (int*)(0x20000410); *a = 0; //okay b = (int*)(0x20000421); *b = 0; //hard fault } 我用的是mdk5, 感觉应该是cpu什么模式没设置对吧? 应该怎么解决这个问题? thx |
Important
It is important to make sure the memory address accessed is aligned. For example, a word size
access can only be carried out on address locations when address bits[1:0] are set to zero, and
a half word size access can only be carried out on address locations when an address bit[0] is
set to zero. The Cortex-M0 processor does not support unaligned transfers. Any attempt at
unaligned memory access results in a hard fault exception. Byte-size transfers are always aligned
on the Cortex-M0 processor.
http://www.jizhuomi.com/software/567.html
好吧,推荐了一个我觉得比较好的个人网站的文章,可能管理员觉得是广告?呵呵
恢复了,可能是以为发的广告