GNU ARM匯編--(九)s3c2440的PWM
/* - copyleft@dndxhej@gmail.com
- */
- .equNOINT,0xc0
- .equGPBCON,0x56000010@led
- .equGPBDAT,0x56000014@led
- .equGPBUP,0x56000018@led
- .equGPFCON,0x56000050@interruptconfig
- .equEINTMASK,0x560000a4
- .equEXTINT0,0x56000088
- .equEXTINT1,0x5600008c
- .equEXTINT2,0x56000090
- .equINTMSK,0x4A000008
- .equEINTPEND,0x560000a8
- .equSUBSRCPND,0x4a000018
- .equINTSUBMSK,0x4a00001c
- .equSRCPND,0X4A000000
- .equINTPND,0X4A000010
- .equGPHCON,0x56000070
- .equGPHDAT,0x56000074
- .equGPB5_out,(1<<(5*2))
- .equGPB6_out,(1<<(6*2))
- .equGPB7_out,(1<<(7*2))
- .equGPB8_out,(1<<(8*2))
- .equGPBVALUE,(GPB5_out|GPB6_out|GPB7_out|GPB8_out)
- .equLOCKTIME,0x4c000000
- .equMPLLCON,0x4c000004
- .equUPLLCON,0x4c000008
- .equM_MDIV,92
- .equM_PDIV,1
- .equM_SDIV,1
- .equU_MDIV,56
- .equU_PDIV,2
- .equU_SDIV,2
- .equCLKDIVN,0x4c000014
- .equDIVN_UPLL,0
- .equHDIVN,1
- .equPDIVN,1@FCLK:HCLK:PCLK=1:2:4
- .equWTCON,0x53000000
- .equPre_scaler,249
- .equwd_timer,1
- .equclock_select,00@316
- .equint_gen,1@開(kāi)中斷
- .equreset_enable,0@關(guān)掉重啟信號(hào)
- .equWTDAT,0x53000004
- .equCount_reload,50000@定時(shí)器定為2SPCLK=100MPCLK/(Pre_scaler+1)/clock_select=100M/(249+1)/16=25k50000/25k=2s
- .equWTCNT,0x53000008
- .equCount,50000
- .equTCFG0,0x51000000
- .equPrescaler1,0x00@[15:8]Timer234
- .equPrescaler0,249@[7:0]Timer01
- .equTCFG1,0x51000004
- .equDMA_MODE,0x0@[23:20]nodmachannal
- .equMUX0,0x2@[3:0]1/8
- @定時(shí)器輸入時(shí)鐘周期=PCLK/(prescaler+1)/(dividervalue)
- @clk=100M/(249+1)/8=25k
- .equTCON,0x51000008
- .equDZ_eable,0@[4]關(guān)閉死區(qū)的操作
- .equauto_reload,1@[3]auto_reload
- .equinverter,1@[2]打開(kāi)電平反轉(zhuǎn)
- .equman_update,1@[1]手動(dòng)更新
- .equclear_man_update,0
- .equstart,1@[0]開(kāi)始
- .equstop,0@[0]停止
- .equTCNTB0,0x5100000c
- .equTCMPB0,0x51000010
- .equTCNTO0,0x51000014
- .equULCON0,0x50000000
- .equIR_MODE,0x0@[6]正常模式
- .equParity_Mode,0x0@[5:3]無(wú)校驗(yàn)位
- .equNum_of_stop_bit,0x0@[2]一個(gè)停止位
- .equWord_length,0b11@[1:0]8個(gè)數(shù)據(jù)位
- .equUCON0,0x50000004
- .equFCLK_Div,0@[15:12]時(shí)鐘源選擇用PCLK,所以這里用默認(rèn)值
- .equClk_select,0b00@[11:10]時(shí)鐘源選擇使用PCLK
- .equTx_Int_Type,1@[9]中斷請(qǐng)求類型為L(zhǎng)evel
- .equRx_Int_Type,0@1@[8]中斷請(qǐng)求類型為L(zhǎng)evel
- .equRx_Timeout,0@[7]
- .equRx_Error_Stat_Int,1@[6]
- .equLoopback_Mode,0@[5]正常模式
- .equBreak_Sig,0@[4]不發(fā)送終止信號(hào)
- .equTx_Mode,0b01@[3:2]中斷請(qǐng)求或輪循模式
- .equRx_Mode,0b01@[1:0]中斷請(qǐng)求或輪循模式
- .equUFCON0,0x50000008
- .equTx_FIFO_Trig_Level,0b00@[7:6]
- .equRx_FIFO_Trig_Level,0b00@[5:4]
- .equTx_FIFO_Reset,0b0@[2]
- .equRx_FIFO_Reset,0b0@[1]
- .equFIFO_Enable,0b0@[0]非FIFO模式
- .equUMCON0,0x5000000C@這個(gè)寄存器可以不管的
- .equUTRSTAT0,0x50000010
- .equUERSTAT0,0x50000014
- .equUFSTAT0,0x50000018
- .equUMSTAT0,0x5000001C
- .equUTXH0,0x50000020@(L小端)
- .equURXH0,0x50000024@(L小端)
- .equUBRDIV0,0x50000028
- .equUBRDIV,0x35@PCLK=400M/4=100MUBRDIV=(int)(100M/115200/16)-1=53=0x35
- .globalBuzzer_Freq_Set
- .global_start
- _start:breset
- ldrpc,_undefined_instruction
- ldrpc,_software_interrupt
- ldrpc,_prefetch_abort
- ldrpc,_data_abort
- ldrpc,_not_used
- @birq
- ldrpc,_irq
- ldrpc,_fiq
- _undefined_instruction:.wordundefined_instruction
- _software_interrupt:.wordsoftware_interrupt
- _prefetch_abort:.wordprefetch_abort
- _data_abort:.worddata_abort
- _not_used:.wordnot_used
- _irq:.wordirq
- _fiq:.wordfiq
- .balignl16,0xdeadbeef
- reset:
- ldrr3,=WTCON
- movr4,#0x0
- strr4,[r3]@disablewatchdog
- ldrr0,=GPBCON
- ldrr1,=0x15400@這個(gè)時(shí)候暫不配置GPB0為TOUT0,這時(shí)候只是配置GPB0為TOUT0
- strr1,[r0]
- ldrr2,=GPBDAT
- ldrr1,=0x160
- strr1,[r2]
- blclock_setup
- bluart_init
- //bldelay
- msrcpsr_c,#0xd2@進(jìn)入中斷模式
- ldrsp,=3072@中斷模式的棧指針定義
- msrcpsr_c,#0xd3@進(jìn)入系統(tǒng)模式
- ldrsp,=4096@設(shè)置系統(tǒng)模式的棧指針
- @--------------------------------------------
- ldrr0,=GPBUP
- ldrr1,=0x03f0
- strr1,[r0]
- ldrr0,=GPFCON
- ldrr1,=0x2ea@0x2
- strr1,[r0]
- ldrr0,=EXTINT0
- @ldrr1,=0x8f888@0x0@0x8f888@~(7|(7<<4)|(7<<8)|(7<<16))//低電平觸發(fā)中斷
- ldrr1,=0xafaaa@0x0@0x8f888//下降沿觸發(fā)中斷
- strr1,[r0]
- ldrr0,=EINTPEND
- ldrr1,=0xf0@0b10000
- strr1,[r0]
- ldrr0,=EINTMASK
- ldrr1,=0x00@0b00000
- strr1,[r0]
- ldrr0,=SRCPND
- ldrr1,=0x3ff@0x1@0b11111
- strr1,[r0]
- ldrr0,=SUBSRCPND
- ldrr1,=0x1<<13
- strr1,[r0]
- ldrr0,=INTPND
- ldrr1,=0x3ff@0x1@0b11111
- strr1,[r0]
- ldrr0,=INTSUBMSK
- ldrr1,=0x0<<13
- strr1,[r0]
- ldrr0,=INTMSK
- ldrr1,=0xfffff000@0b00000
- strr1,[r0]
- MRSr1,cpsr
- BICr1,r1,#0x80
- MSRcpsr_c,r1
- blmain
- irq:
- sublr,lr,#4
- stmfdsp!,{r0-r12,lr}
- blirq_isr
- ldmfdsp!,{r0-r12,pc}^
- irq_isr:
- ldrr2,=GPBDAT
- ldrr1,=0x0e0
- strr1,[r2]
- ldrr0,=EINTPEND
- ldrr1,=0xf0
- strr1,[r0]
- ldrr0,=SRCPND
- ldrr1,=0x3ff@0b11111
- strr1,[r0]
- ldrr0,=SUBSRCPND
- ldrr1,=0x3ff@0x1<<13
- strr1,[r0]
- ldrr0,=INTPND
- ldrr1,=0x3ff@0b11111
- strr1,[r0]
- movpc,lr
- delay:
- ldrr3,=0xffffff
- delay1:
- subr3,r3,#1
- cmpr3,#0x0
- bnedelay1
- movpc,lr
- clock_setup:
- ldrr0,=LOCKTIME
- ldrr1,=0xffffffff
- strr1,[r0]
- ldrr0,=CLKDIVN
- ldrr1,=(DIVN_UPLL<<3)|(HDIVN<<1)|(PDIVN<<0)
- strr1,[r0]
- ldrr0,=UPLLCON
- ldrr1,=(U_MDIV<<12)|(U_PDIV<<4)|(U_SDIV<<0)@Fin=12MUPLL=48M
- strr1,[r0]
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- ldrr0,=MPLLCON
- ldrr1,=(M_MDIV<<12)|(M_PDIV<<4)|(M_SDIV<<0)@Fin=12MFCLK=400M
- strr1,[r0]
- movpc,lr
- uart_init:
- ldrr0,=GPHCON
- ldrr1,=0x2aaaa@配置GPIO復(fù)用規(guī)則為串口
- strr1,[r0]
- ldrr0,=ULCON0
- ldrr1,=(IR_MODE<<6)|(Parity_Mode<<3)|(Num_of_stop_bit<<2)|(Word_length<<0)@
- strr1,[r0]
- ldrr0,=UCON0
- ldrr1,=(FCLK_Div<<12)|(Clk_select<<10)|(Tx_Int_Type<<9)|(Rx_Int_Type<<8)|(Rx_Timeout<<7)|(Rx_Error_Stat_Int<<6)|(Loopback_Mode<<5)|(Break_Sig<<4)|(Tx_Mode<<2)|(Rx_Mode<<0)
- strr1,[r0]
- ldrr0,=UFCON0
- ldrr1,=(Tx_FIFO_Trig_Level<<6)|(Rx_FIFO_Trig_Level<<4)|(Tx_FIFO_Reset<<2)|(Rx_FIFO_Reset<<1)|(FIFO_Enable<<0)@
- strr1,[r0]
- ldrr0,=UBRDIV0
- ldrr1,=(UBRDIV<<0)
- strr1,[r0]
- movpc,lr
- Buzzer_Freq_Set:
- //ldrr0,=GPBCON
- //ldrr1,=0x15400@這個(gè)時(shí)候暫不配置GPB0為TOUT0,這時(shí)候只是配置GPB0為TOUT0
- //strr1,[r0]
- ldrr2,=GPBDAT
- ldrr1,=0x1c1
- strr1,[r2]
- ldrr2,=GPBCON
- ldrr1,[r2]
- ldrr1,[r1]
- //ldrr1,=0x15400
- bicr1,r1,#0x3
- orrr1,r1,#0x2
- strr1,[r2]
- ldrr2,=GPBDAT
- ldrr1,=0x1a0
- strr1,[r2]
- ldrr1,=TCFG0
- ldrr2,=(Prescaler0<<0)
- strr2,[r1]
- ldrr1,=TCFG1
- ldrr2,=(DMA_MODE<<20)|(MUX0<<0)
- strr2,[r1]
- //ldrr3,[r0]
- //strr3,[r2]
評(píng)論