Title: C????
1???? ? C????
2??
- ??ppt???????????C????SPCE061A????????
- ????ppt?????????
3??
- ??C????
- ??C????
- C???????
- ?C???????
4??C????
5?C???????
- ??????????????????
- ??????????,?????????
- ?????????,????????
6?C?????????SPCE061A????
- IDE?????C???????,C???????????????????
- Software Libraries
- Standard C library
- Hardware library
- SACM ( Sunplus audio coding method)
7??C????
8unSP GCC?????????????
???? ????(bit) ??
char 16 -3276832767
short,int 16 -3276832767
long 32 -21474836482147483647
unsigned char 16 065535
unsigned short unsigned int 16 065535
unsigned long 32 04294967295
float,double 32 ?IEEE?????32????
9???????????
- char?unsigned char?16?
- ?????????GCC????????????
- float?double????32????
- unSP???float?double???32??64?????
10?????signed?unsigned
- ????signed?unsigned??????,???????????
- ????signed?unsigned??????????????,??signed?unsig
ned,?????????????????, - ????unsigned???
- ????,??????????????????????,????unsigned???
11????????
- unSP IDE?Turbo C??,?????????????,???
- i3printf("d,d",i,i)
-
?? 4,3
12????
13C???????
14?????????
15C??????
- ????????????_???
- ??C???????????????_????
- ????????,????????(????)??????
- ?????16??????????R1??32???????????R1?R2??????R1?,
???R2??
16C????????
extern int ADD() int main(void) int i,j,SUM i2 j3 SUMADD(i,j) return 0 .CODE .PUBLIC _ADD _ADD.PROC PUSH BP TO SP BP SP 1 R1 BP3 //??????? R2 BP4 //??????? R1 R2 POP BP FROM SP RETF .ENDP
17????C???
EXTERNAL _ADD .RAM .VAR SUM .CODE .PUBLIC _main _main R1 3 PUSH R1 TO SP //?2??? //?? R1 2 PUSH R1 TO SP //?1??? //?? CALL _ADD SUMR1 SP2 //??SP?? .END
EXTERNAL _ADD .RAM .VAR SUM .CODE .PUBLIC _main _main R1 3 PUSH R1 TO SP //?2??? //?? R1 2 C?? int ADD(int i,int j) iij return i
18C???????
- ????????
- asm (??????????????)
19?????????????
- ?C?P_IOA_Dir??0x1234,????????????
- asm(.define P_IOA_Dir 0x7002)
- int main(void)
-
- asm("P_IOA_Dir 0" "r"(0x1234))
-
20?????????????
- ?P_IOA_Dir????????C????int??j? ,??????????
- asm(.define P_IOA_Dir 0x7002)
- int main(void)
-
- int j
- asm("0 P_IOA_Dir" "r"(j))
-
21?C???????
22???C????????
- define P_IOA_Dir (volatile unsigned int
)0x7002 - int main(void)
-
- int j
- P_IOA_Dir0x1234
- j P_IOA_Dir
-
23?C??IO??
- //??A??????????
- P_IOA_Dir 0
- P_IOA_Attrib 0
- P_IOA_Data 0
-
- //??B?????????
- P_IOA_Dir 0xffff
- P_IOB_Attrib 0xffff
- P_IOB_Data 0
24?C????????
PLL?? ???? 32K?? CPUclk??
b15b8 b7b5 b4 b3 b2b0
- define P_SystemClock (volatile unsigned int
)0x7013 - P_SystemClock System_Information
- System Information CPU Clock 32K Mode 32K
Status Fosc
25?C????????
- CPU Clock??????????
- C_Fosc ? Fosc
- C_Fosc_Div_2 ? Fosc/2
- C_Fosc_Div_4 ? Fosc/4
- C_Fosc_Div_8 ? Fosc/8 (???)
- C_Fosc_Div_16 ? Fosc/16
- C_Fosc_Div_32 ? Fosc/32
- C_Fosc_Div_64 ? Fosc/64
- C_Sleep ? Stop (??)
26?C????????
- 32K Hz Mode ??????????
- C_StrongMode ?????
- C_AutoMode ????? (???)
- 32K Hz Sleep Status??????????
- C_32K_Work? ???,32K????? (??)
- C_32K_Off ? ???,32K??????
27?C????????
- Fosc??????????
- C_Fosc_24M ? 24.576M (???)
- C_Fosc_20M ? 20.480M
- C_Fosc_32M ? 32.768M
- C_Fosc_40M ? 40.960M
- C_Fosc_49M ? 49.152M
28?C????????
- ???????????????????????Fosc_CLK?CPU_CLK,??????????
?? - ????A???????????????
- ????Fosc_CLK?CPU_CLK???,??????????????
29?C????????
- ????
- include "SPCE061V004.H"
- void Delay()
- define Fosc_CLK_RATE C_Fosc_49M //Fosc
- define CPU_CLK_RATE C_Fosc_Div_2 //CPUClk
30?C????????
- main()
-
- unsigned int Fosc_CLK,CPU_CLK
- P_IOA_Dir 0x00FF // IOA 7..0 output
- P_IOA_Attrib 0x00FF
- P_IOA_Data 0
31?C????????
- Fosc_CLK Fosc_CLK_RATE
- CPU_CLK CPU_CLK_RATE
- P_SystemClock Fosc_CLKCPU_CLK
32?C????????
- while(1)
-
- P_IOA_Data 0x00FF //LED off
- Delay()
- P_IOA_Data 0 //LED on
- Delay()
-
33?C?????
- ?IDE162?,???????????(???????)???
- ?IDE180?,????????,??????C?????
34?C?????
C ASM ??
INT_OFF() int off ??????
INT_IRQ() int irq ???irq??
INT_FIQ() int fiq ???fiq??
INT_FIQ_IRQ() int fiq,irq ??fiq?irq??
IRQ_OFF() irq off ??irq??
IRQ_ON() irq on ??irq??
FIQ_OFF() fiq off ??fiq??
FIQ_ON() fiq on ??fiq??
35?C?????
- ????0.5s,?A??8???????
- ????0.5s??????????????SPCE061A???????????,?2Hz?4H
z?8Hz?16Hz?32Hz?64Hz?128Hz?256Hz?512Hz?1024H?2048H
z?4096Hz????????????????2Hz????????????????2Hz????
???,?????0.5s??????
36?C?????
- include SPCE061V004.H
- include unSPMACRO.h
- main()
- INT_OFF()
- P_IOA_Dir0x00FF
- P_IOA_Attrib0x00FF
- P_IOA_Data0x0000
- P_INT_CtrlC_IRQ5_2Hz//Setup interrupt
- INT_IRQ()
- while(1) P_Watchdog_Clear C_WDTCLR
37?C?????
- include "SPCE061V004.H"
- unsigned int g_uiOutput0x0000
- void IRQ5(void) __attribute__ ((ISR))
- void IRQ5(void)
- if(P_INT_CtrlC_IRQ5_2Hz)
- //IRQ5_2Hz
- P_IOA_Datag_uiOutput
- g_uiOutput 0xffff
- P_INT_ClearC_IRQ5_2Hz
-
38??
- ??????????,??????????????????????????????????
- ????,?AD?DA?Timer?UART?SIO?,??????????????????,???
?? - ????????C?SPCE061A???????,??????????(www.unsp.com.
cn)??C????????????????
39????