1、合泰单片机总结-测试环境 C 编译器 V21. Debug2.3. .数组,支持一维/二维数组 (大小小于 1 bank);4. 使用 const 关键字,变量将存储于程序存储区,如,const uint8_t tab = “1,2,3”;5. 中断服务函数:#pragma vector ISR_tmr0 0x0c /定义中断入口地址void ISR_tmr0(void)tick+ ;6. 中断函数中调用普通函数(1)方法 1#pragma vector ISR_tmr0 0x0c#pragma nolocal funfun()void ISR_tmr0(void)fun() ;(2)方法 2
2、#pragma vector ISR_tmr0 0x0cfun()void ISR_tmr0(void)#asmcall _fun;#endasm7. 宏定义#define _pa0 _12_0 /bit 0 of RAM address 0x128. 位变量定义对于有多个 bank 的 MCU,位变量只能定义在 bank0,使用如下方式#pragma rambank0bit flag ;#pragma norambank9. 指针(1) 不支持指向“字符串数组”char *rainbow = “red“, “orange“, “yellow“ ;/ not supported(2) 只支持全
3、局的静态函数指针,且所指函数不能带有参数fun()return 1;int (*const p)() =fun; / global and initialization requiredvoid main()int a;a=(*p)();(3) 不支持取得 const 常量的地址const int ldc = 0;void main()int *a;a = / cannot pass10. 内嵌汇编#asmlabel: opcode operands.#endasmEg:char a;int b;void fun(char p1,int p2)a = p1;#asm / b = p2;MOV
4、A,fun1MOV _b,AMOV A,fun11mov _b1,A#endasmvoid main()int d1;char d2;unsigned char q, r;r = 0;q = d1 / d2; / get quotient#asm / r = q;MOV A, CR3 ; CR3qMOV CR4,A ; CR4r#endasm#asm / fun(d2,d1)MOV A,CR2 MOV fun0,A ; p1 = d2MOV A,CR1MOV fun1,AMOV A,CR11 MOV fun11,A ; p2 = d1CALL _fun#endasm11. 预编译指令12. 编译器特殊选项13. 内嵌函数 14. 注意事项