rt-thread hard fault 总是指向同一个地方,但不知道错在哪
rt_err_t CopyToDecoderBuf(u8 *pData){
static u8 i;
// RT_ASSERT(pWriteEncodeData->Ready == 0);//decoder没有缓冲区了
rt_mutex_take(EncodeDataBuffermutex,RT_WAITING_FOREVER);
if(pWriteEncodeData->Ready != 0 ) //老是有hard falut 指向这里
{
rt_mutex_release(EncodeDataBuffermutex);
rt_kprintf("缓冲区没有空的\r\n");
return RT_ERROR;
}
for(i=0;i<20;i++)pWriteEncodeData->Data=*pData++;
pWriteEncodeData->Ready=1;
pWriteEncodeData=pWriteEncodeData->next;
rt_mutex_release(EncodeDataBuffermutex);
// rt_kprintf("Got a new voice data\r\n");
return RT_EOK;
}
------------------------------------------------------------------
205: rt_err_t CopyToDecoderBuf(u8 *pData)
0x08017668 BD10 POP {r4,pc}
0x0801766A 4A5C LDR r2,; @0x080177DC
0x0801766C 23BB MOVS r3,#0xBB
0x0801766E 329D ADDS r2,r2,#0x9D
0x08017670 A16E ADR r1,{pc}+4; @0x0801782C
0x08017672 A05E ADR r0,{pc}+2; @0x080177EC
0x08017674 F7EBFCEBBL.W rt_kprintf (0x0800304E)
0x08017678 E7FE B 0x08017678
206: {
207: static u8 i;
208: // RT_ASSERT(pWriteEncodeData->Ready == 0);//decoder没有缓冲区了
0x0801767A B570 PUSH {r4-r6,lr}
209: rt_mutex_take(EncodeDataBuffermutex,RT_WAITING_FOREVER);
0x0801767C 4C69 LDR r4,; @0x08017824
0x0801767E 4605 MOV r5,r0
0x08017680 F04F31FFMOV r1,#0xFFFFFFFF
0x08017684 69A0 LDR r0,
0x08017686 F7EAFAEABL.W rt_mutex_take (0x08001C5E)
210: if(pWriteEncodeData->Ready != 0 ) //老是有hard falut 指向这里 在汇编中指向读取Ready的值
211: {
0x0801768A 6960 LDR r0,
0x0801768C 7801 LDRB r1,
0x0801768E B139 CBZ r1,0x080176A0
212: rt_mutex_release(EncodeDataBuffermutex);
0x08017690 69A0 LDR r0,
0x08017692 F7EAFBACBL.W rt_mutex_release (0x08001DEE)
213: rt_kprintf("缓冲区没有空的\r\n");
214:
0x08017696 A086 ADR r0,{pc}+2; @0x080178B0
0x08017698 F7EBFCD9BL.W rt_kprintf (0x0800304E)
215: return RT_ERROR;
216: }
217: for(i=0;i<20;i++)pWriteEncodeData->Data=*pData++;
218: pWriteEncodeData->Ready=1;
219: pWriteEncodeData=pWriteEncodeData->next;
220:
221: rt_mutex_release(EncodeDataBuffermutex);
222:
223: // rt_kprintf("Got a new voice data\r\n");
224:
225: return RT_EOK;
0x0801769C 2001 MOVS r0,#0x01
226: }
rtt 给出的信息
psr: 0x41000000
pc: 0x0801768c
lr: 0x08001dcf
r12: 0x00000000
r03: 0xffffffff
r02: 0x6c00966c
r01: 0x00000000
r00: 0xa00ab8e0
hard fault on thread: USART1R 我在读出数据时也是使用了互斥量,按理说应该不会出现读写冲突的。
有时一直不出现hard fault 0x0801768A 6960 LDR r0,
0x0801768C 7801 LDRB r1,
空指针检查不是检查0,而是写NULL,虽然一般是0。
这两条指令检查 R4, R0
R4就是 pWriteEncodeData 回复【2楼】aozima
-----------------------------------------------------------------------
"空指针检查不是检查0,而是写NULL,虽然一般是0 ",我没有检查指针啊,系统检查检查吗
页:
[1]