一段DSP代码,两个问题,敬请指点
Uint16 data_buff[256]={0x1234,0x5678,0xaa55,0x55aa}; Uint16 FAT32data_buff[512]; unsigned long lb2bb(unsigned char *dat,unsigned char len); void main() { Uint32 i, temp=0; unsigned char BPB_temp=0x00; struct FAT32_Init_Arg *arg; struct FAT32_BPB *bpb=(struct FAT32_BPB *)(FAT32data_buff); CSL_init(); SdRead_Sector(temp,data_buff); asm(" nop ");
if(FAT32data_buff[0]==0xeb && FAT32data_buff[2]==0x90) asm(" nop ") ; BPB_temp=lb2bb((bpb->BPB_FATSz32),4); arg->FATsectors =BPB_temp; asm(" nop "); A处 arg->FirstDirClust =lb2bb((bpb->BPB_RootClus) ,4); asm(" nop "); arg->BytesPerSector =lb2bb((bpb->BPB_BytesPerSec),2); B处 asm(" nop "); //每扇区字节数 arg->SectorsPerClust =lb2bb((bpb->BPB_SecPerClus) ,1); C处 asm(" nop "); arg->FirstFATSector =lb2bb((bpb->BPB_RsvdSecCnt) ,2)+arg->BPB_Sector_No;//第一个FAT表扇区 asm(" nop ");
1 程序执行到A处,BPB_temp类型为unsigned char ,数值0x792,而结构体的arg->FirstDirClust类型为unsigned int ,数据值变为0x1C12,不是所希望的0x792,不知道怎么回事,请指点一下。 2 程序执行A,B,都没有问题,但是执行到C就抛飞,与硬件仿真器自动断开,lb2bb在A和B都没有问题而在C处怎么存在问题? 3 Arg和bpb都是512字节的变量,CMD中设置-heap大小为1000字节。
|