本人用过三星单片机如S3F9488、S3F9454、S3F9498,以前一直是用汇编编程OPENICE-I500,现在改用C,遇到几个小问题已解决的或未解决的,希望能与各位聊聊,以增加对C语言的了解.
1、头文件:S3F9488的头文件用ioS3C9488.h,因为S3F9488与S3C9488的规格书是相同的只是前者是FLASH,后者是OTP,
2、编译后.lst文件会有如AND 0xDF,#252的语句,从语句分析是编译器指向PAGE0,但实际我没有用到PAGE1,一直是在PAGE0操作.(只针对9488,其它不知是否也会)
如果各位有汇编或C语言的问题,请提出,我尽力给你答复
Samsung单片机C语言(IAR)应用
全部回复(8)
正序查看
倒序查看
现在还没有回复呢,说说你的想法
先自顶
以下是一段24C02的程序
void AT24CXX_WriteFullPage( unsigned int wAddress , unsigned char* pBuffer )
{
unsigned char ucVar;
while ( AT24CXX_Enabled() == FALSE );
AT24CXX_Start();
AT24CXX_SetWriteAddress( wAddress );
for ( ucVar = 0 ; ucVar < AT24CXX_PAGESIZE ; ucVar ++ )
AT24CXX_Write( pBuffer[ ucVar ] );
AT24CXX_Stop();
}
/******************************************************************************/
下面是编译后的.lst文件
\ In segment CODE, align 1, keep-with-next
193 void AT24CXX_WriteFullPage( unsigned int wAddress , unsigned char* pBuffer )
\ AT24CXX_WriteFullPage:
\ 0000 REQUIRE __INIT_STACK
194 {
\ 0000 ; * Stack frame (at entry) *
\ 0000 ; Param size: 0
\ 0000
\ 0000 70C9 PUSH R9
\ 0002 70C8 PUSH R8
\ 0004 70C7 PUSH R7
\ 0006 70C6 PUSH R6
\ 0008 ; Saved register size: 4
\ 0008 ; Auto size: 0
\ 0008 68CE LD R6,R14
\ 000A 78CF LD R7,R15
\ 000C 88CC LD R8,R12
\ 000E 98CD LD R9,R13
195 unsigned char ucVar;
196
197 while ( AT24CXX_Enabled() == FALSE );
\ ??AT24CXX_WriteFullPage_0:
\ 0010 ; Setup parameters for call to function AT24CXX_Enabled
\ 0010 F6.... CALL AT24CXX_Enabled
\ 0013 42FF OR R15,R15
\ 0015 6BF9 JR Z,??AT24CXX_WriteFullPage_0
198 AT24CXX_Start();
\ 0017 ; Setup parameters for call to function AT24CXX_Start
\ 0017 F6.... CALL AT24CXX_Start
199 AT24CXX_SetWriteAddress( wAddress );
\ 001A ; Setup parameters for call to function AT24CXX_SetWriteAddress
\ 001A E8C6 LD R14,R6
\ 001C F8C7 LD R15,R7
\ 001E F6.... CALL AT24CXX_SetWriteAddress
200 for ( ucVar = 0 ; ucVar < AT24CXX_PAGESIZE ; ucVar ++ )
\ 0021 B0C7 CLR R7
\ 0023 8B12 JR ??main_4
201 AT24CXX_Write( pBuffer[ ucVar ] );
\ ??AT24CXX_WriteFullPage_1:
\ 0025 ; Setup parameters for call to function AT24CXX_Write
\ 0025 E8C8 LD R14,R8
\ 0027 F8C9 LD R15,R9
\ 0029 02F7 ADD R15,R7
\ 002B 44CEDF OR 0xDF,R14
\ 002E C7FF LD R15,@R15
\ 0030 56DFFC AND 0xDF,#252
\ 0033 F6.... CALL AT24CXX_Write
\ 0036 7E INC R7
\ ??main_4:
\ 0037 A6C708 CP R7,#8
\ 003A 7BE9 JR ULT,??AT24CXX_WriteFullPage_1
202 AT24CXX_Stop();
\ 003C ; Setup parameters for call to function AT24CXX_Stop
\ 003C F6.... CALL AT24CXX_Stop
203 }
\ 003F 50C6 POP R6
\ 0041 50C7 POP R7
\ 0043 50C8 POP R8
\ 0045 50C9 POP R9
\ 0047 AF RET
\ 0048 REQUIRE ?CLSAM8_2_L00
204 /******************************************************************************/
205
问题就在于有AND 0xDF,#252的行,还有就是入栈,这并不是在中断,可是却有入栈?哪位高手来讲述一下.
以下是一段24C02的程序
void AT24CXX_WriteFullPage( unsigned int wAddress , unsigned char* pBuffer )
{
unsigned char ucVar;
while ( AT24CXX_Enabled() == FALSE );
AT24CXX_Start();
AT24CXX_SetWriteAddress( wAddress );
for ( ucVar = 0 ; ucVar < AT24CXX_PAGESIZE ; ucVar ++ )
AT24CXX_Write( pBuffer[ ucVar ] );
AT24CXX_Stop();
}
/******************************************************************************/
下面是编译后的.lst文件
\ In segment CODE, align 1, keep-with-next
193 void AT24CXX_WriteFullPage( unsigned int wAddress , unsigned char* pBuffer )
\ AT24CXX_WriteFullPage:
\ 0000 REQUIRE __INIT_STACK
194 {
\ 0000 ; * Stack frame (at entry) *
\ 0000 ; Param size: 0
\ 0000
\ 0000 70C9 PUSH R9
\ 0002 70C8 PUSH R8
\ 0004 70C7 PUSH R7
\ 0006 70C6 PUSH R6
\ 0008 ; Saved register size: 4
\ 0008 ; Auto size: 0
\ 0008 68CE LD R6,R14
\ 000A 78CF LD R7,R15
\ 000C 88CC LD R8,R12
\ 000E 98CD LD R9,R13
195 unsigned char ucVar;
196
197 while ( AT24CXX_Enabled() == FALSE );
\ ??AT24CXX_WriteFullPage_0:
\ 0010 ; Setup parameters for call to function AT24CXX_Enabled
\ 0010 F6.... CALL AT24CXX_Enabled
\ 0013 42FF OR R15,R15
\ 0015 6BF9 JR Z,??AT24CXX_WriteFullPage_0
198 AT24CXX_Start();
\ 0017 ; Setup parameters for call to function AT24CXX_Start
\ 0017 F6.... CALL AT24CXX_Start
199 AT24CXX_SetWriteAddress( wAddress );
\ 001A ; Setup parameters for call to function AT24CXX_SetWriteAddress
\ 001A E8C6 LD R14,R6
\ 001C F8C7 LD R15,R7
\ 001E F6.... CALL AT24CXX_SetWriteAddress
200 for ( ucVar = 0 ; ucVar < AT24CXX_PAGESIZE ; ucVar ++ )
\ 0021 B0C7 CLR R7
\ 0023 8B12 JR ??main_4
201 AT24CXX_Write( pBuffer[ ucVar ] );
\ ??AT24CXX_WriteFullPage_1:
\ 0025 ; Setup parameters for call to function AT24CXX_Write
\ 0025 E8C8 LD R14,R8
\ 0027 F8C9 LD R15,R9
\ 0029 02F7 ADD R15,R7
\ 002B 44CEDF OR 0xDF,R14
\ 002E C7FF LD R15,@R15
\ 0030 56DFFC AND 0xDF,#252
\ 0033 F6.... CALL AT24CXX_Write
\ 0036 7E INC R7
\ ??main_4:
\ 0037 A6C708 CP R7,#8
\ 003A 7BE9 JR ULT,??AT24CXX_WriteFullPage_1
202 AT24CXX_Stop();
\ 003C ; Setup parameters for call to function AT24CXX_Stop
\ 003C F6.... CALL AT24CXX_Stop
203 }
\ 003F 50C6 POP R6
\ 0041 50C7 POP R7
\ 0043 50C8 POP R8
\ 0045 50C9 POP R9
\ 0047 AF RET
\ 0048 REQUIRE ?CLSAM8_2_L00
204 /******************************************************************************/
205
问题就在于有AND 0xDF,#252的行,还有就是入栈,这并不是在中断,可是却有入栈?哪位高手来讲述一下.
0
回复
提示