c8051f330程序

控制/MCU

1877人已加入

描述

c8051f330 C程序源代码

c8051f330 led灯(汇编)程序

;$include (c8051f330.inc)    ;IDE 环境使用   
;$include (c8051f330my.inc)    ;KEIL 环境使用
LED  equ p2.0            ;LED='0' means ON
timebuf  equ 30h       
;               Programma Initiation
;***********************************************************
  org 0000h
  ljmp main
  org 000bh
  ljmp tmr_int0
  
  org 0030h
main:  
  anl PCA0MD, #10111111b        ; WDTE = 0 (clear watchdog timer enable)
blank:  mov @r0, #0
  djnz r0, blank
;***********************************************************
;               Programma Initiation
;***********************************************************
  mov sp, #60h
  mov P1SKIP, #00h
  setb LED
  mov P2MDOUT, #00h
  mov XBR0, #00h ;Enable UART on P0.4(TX) and P0.5(RX)                    
  mov XBR1, #40h ;Enable crossbar and weak pull-ups
  
  mov OSCICN, #83h ;Configure internal oscillator for its maximum frequency 24.5MHz
  mov RSTSRC, #04h ;Enable missing clock detector
  mov TMOD, #01h
  mov CKCON, #01h
  mov TL0, #0beh
  mov TH0, #10h
  clr TR0
  mov IP, #02h
  mov timebuf, #00h
  setb TR0
  
  jmp $
;***********************************************************
;               time 0 intrrupt ,10ms
;***********************************************************
tmr_int0:
  mov TL0, #0beh
  mov TH0, #10h
 
  inc timebuf
  mov a, #50
  cjne a, timebuf, tmr_out
  mov timebuf, #00h
  cpl LED
tmr_out: 
  setb TR0
  reti
 
;
; FILE NAME: C8051F330MY.INC
; TARGET MCUs: C8051F330, F331
; DESCRIPTION: Register/bit definitions for the C8051F330 product family.
;
; REVISION 1.0
;
;---------------------------------------------------------------------------
;
;P0             DATA 080H    ; PORT 0 LATCH
;SP             DATA 081H    ; STACK POINTER
;DPL            DATA 082H    ; DATA POINTER LOW
;DPH            DATA 083H    ; DATA POINTER HIGH
;PCON           DATA 087H    ; POWER CONTROL
;TCON           DATA 088H    ; TIMER/COUNTER CONTROL
;TMOD           DATA 089H    ; TIMER/COUNTER MODE
;TL0            DATA 08AH    ; TIMER/COUNTER 0 LOW
;TL1            DATA 08BH    ; TIMER/COUNTER 1 LOW
;TH0            DATA 08CH    ; TIMER/COUNTER 0 HIGH
;TH1            DATA 08DH    ; TIMER/COUNTER 1 HIGH
CKCON          DATA 08EH    ; CLOCK CONTROL
PSCTL          DATA 08FH    ; PROGRAM STORE R/W CONTROL
;P1             DATA 090H    ; PORT 1 LATCH
TMR3CN         DATA 091H    ; TIMER/COUNTER 3 CONTROL
TMR3RLL        DATA 092H    ; TIMER/COUNTER 3 RELOAD LOW
TMR3RLH        DATA 093H    ; TIMER/COUNTER 3 RELOAD HIGH
TMR3L          DATA 094H    ; TIMER/COUNTER 3 LOW
TMR3H          DATA 095H    ; TIMER/COUNTER 3 HIGH
IDA0L          DATA 096H    ; CURRENT MODE DAC0 LOW
IDA0H          DATA 097H    ; CURRENT MODE DAC0 HIGH
SCON0          DATA 098H    ; UART0 CONTROL
SBUF0          DATA 099H    ; UART0 DATA BUFFER
CPT0CN         DATA 09BH    ; COMPARATOR0 CONTROL
CPT0MD         DATA 09DH    ; COMPARATOR0 MODE SELECTION
CPT0MX         DATA 09FH    ; COMPARATOR0 MUX SELECTION
;P2             DATA 0A0H    ; PORT 2 LATCH
SPI0CFG        DATA 0A1H    ; SPI CONFIGURATION
SPI0CKR        DATA 0A2H    ; SPI CLOCK RATE CONTROL
SPI0DAT        DATA 0A3H    ; SPI DATA
P0MDOUT        DATA 0A4H    ; PORT 0 OUTPUT MODE CONFIGURATION
P1MDOUT        DATA 0A5H    ; PORT 1 OUTPUT MODE CONFIGURATION
P2MDOUT        DATA 0A6H    ; PORT 2 OUTPUT MODE CONFIGURATION
;IE             DATA 0A8H    ; INTERRUPT ENABLE
CLKSEL         DATA 0A9H    ; CLOCK SELECT
EMI0CN         DATA 0AAH    ; EXTERNAL MEMORY INTERFACE CONTROL
OSCXCN         DATA 0B1H    ; EXTERNAL OSCILLATOR CONTROL
OSCICN         DATA 0B2H    ; INTERNAL OSCILLATOR CONTROL
OSCICL         DATA 0B3H    ; INTERNAL OSCILLATOR CALIBRATION
FLSCL          DATA 0B6H    ; FLASH SCALE
FLKEY          DATA 0B7H    ; FLASH LOCK AND KEY
;IP             DATA 0B8H    ; INTERRUPT PRIORITY
IDA0CN         DATA 0B9H    ; CURRENT MODE DAC0 CONTROL
AMX0N          DATA 0BAH    ; AMUX0 NEGATIVE CHANNEL SELECT
AMX0P          DATA 0BBH    ; AMUX0 POSITIVE CHANNEL SELECT
ADC0CF         DATA 0BCH    ; ADC0 CONFIGURATION
ADC0L          DATA 0BDH    ; ADC0 LOW
ADC0H          DATA 0BEH    ; ADC0 HIGH
SMB0CN         DATA 0C0H    ; SMBUS CONTROL
SMB0CF         DATA 0C1H    ; SMBUS CONFIGURATION
SMB0DAT        DATA 0C2H    ; SMBUS DATA
ADC0GTL        DATA 0C3H    ; ADC0 GREATER-THAN COMPARE LOW
ADC0GTH        DATA 0C4H    ; ADC0 GREATER-THAN COMPARE HIGH
ADC0LTL        DATA 0C5H    ; ADC0 LESS-THAN COMPARE WORD LOW
ADC0LTH        DATA 0C6H    ; ADC0 LESS-THAN COMPARE WORD HIGH
TMR2CN         DATA 0C8H    ; TIMER/COUNTER 2 CONTROL
TMR2RLL        DATA 0CAH    ; TIMER/COUNTER 2 RELOAD LOW
TMR2RLH        DATA 0CBH    ; TIMER/COUNTER 2 RELOAD HIGH
TMR2L          DATA 0CCH    ; TIMER/COUNTER 2 LOW
TMR2H          DATA 0CDH    ; TIMER/COUNTER 2 HIGH
;PSW            DATA 0D0H    ; PROGRAM STATUS WORD
REF0CN         DATA 0D1H    ; VOLTAGE REFERENCE CONTROL
P0SKIP         DATA 0D4H    ; PORT 0 SKIP
P1SKIP         DATA 0D5H    ; PORT 1 SKIP
PCA0CN         DATA 0D8H    ; PCA CONTROL
PCA0MD         DATA 0D9H    ; PCA MODE
PCA0CPM0       DATA 0DAH    ; PCA MODULE 0 MODE REGISTER
PCA0CPM1       DATA 0DBH    ; PCA MODULE 1 MODE REGISTER
PCA0CPM2       DATA 0DCH    ; PCA MODULE 2 MODE REGISTER
;ACC            DATA 0E0H    ; ACCUMULATOR
XBR0           DATA 0E1H    ; PORT I/O CROSSBAR CONTROL 0
XBR1           DATA 0E2H    ; PORT I/O CROSSBAR CONTROL 1
OSCLCN         DATA 0E3H    ; LOW-FREQUENCY OSCILLATOR CONTROL
IT01CF         DATA 0E4H    ; INT0/INT1 CONFIGURATION
EIE1           DATA 0E6H    ; EXTENDED INTERRUPT ENABLE 1
ADC0CN         DATA 0E8H    ; ADC0 CONTROL
PCA0CPL1       DATA 0E9H    ; PCA CAPTURE 1 LOW
PCA0CPH1       DATA 0EAH    ; PCA CAPTURE 1 HIGH
PCA0CPL2       DATA 0EBH    ; PCA CAPTURE 2 LOW
PCA0CPH2       DATA 0ECH    ; PCA CAPTURE 2 HIGH
RSTSRC         DATA 0EFH    ; RESET SOURCE CONFIGURATION/STATUS
;B              DATA 0F0H    ; B REGISTER
P0MDIN         DATA 0F1H    ; PORT 0 INPUT MODE CONFIGURATION
P1MDIN         DATA 0F2H    ; PORT 1 INPUT MODE CONFIGURATION
EIP1           DATA 0F6H    ; EXTENDED INTERRUPT PRIORITY 1
SPI0CN         DATA 0F8H    ; SPI CONTROL
PCA0L          DATA 0F9H    ; PCA COUNTER LOW
PCA0H          DATA 0FAH    ; PCA COUNTER HIGH
PCA0CPL0       DATA 0FBH    ; PCA CAPTURE 0 LOW
PCA0CPH0       DATA 0FCH    ; PCA CAPTURE 0 HIGH
VDM0CN         DATA 0FFH    ; VDD MONITOR CONTROL
;------------------------------------------------------------------------------
;BIT DEFINITIONS
;
; TCON 088H
;TF1            BIT 08FH     ; TIMER 1 OVERFLOW FLAG
;TR1            BIT 08EH     ; TIMER 1 ON/OFF CONTROL
;TF0            BIT 08DH     ; TIMER 0 OVERFLOW FLAG
;TR0            BIT 08CH     ; TIMER 0 ON/OFF CONTROL
;IE1            BIT 08BH     ; EXT. INTERRUPT 1 EDGE FLAG
;IT1            BIT 08AH     ; EXT. INTERRUPT 1 TYPE
;IE0            BIT 089H     ; EXT. INTERRUPT 0 EDGE FLAG
;IT0            BIT 088H     ; EXT. INTERRUPT 0 TYPE
S0MODE         BIT 09FH     ; UART 0 MODE
MCE0           BIT 09DH     ; UART 0 MCE
REN0           BIT 09CH     ; UART 0 RX ENABLE
TB80           BIT 09BH     ; UART 0 TX BIT 8
RB80           BIT 09AH     ; UART 0 RX BIT 8
TI0            BIT 099H     ; UART 0 TX INTERRUPT FLAG
RI0            BIT 098H     ; UART 0 RX INTERRUPT FLAG
;EA             BIT 0AFH     ; GLOBAL INTERRUPT ENABLE
ESPI0          BIT 0AEH     ; SPI0 INTERRUPT ENABLE
ET2            BIT 0ADH     ; TIMER 2 INTERRUPT ENABLE
ES0            BIT 0ACH     ; UART0 INTERRUPT ENABLE
;ET1            BIT 0ABH     ; TIMER 1 INTERRUPT ENABLE
;EX1            BIT 0AAH     ; EXTERNAL INTERRUPT 1 ENABLE
;ET0            BIT 0A9H     ; TIMER 0 INTERRUPT ENABLE
;EX0            BIT 0A8H     ; EXTERNAL INTERRUPT 0 ENABLE
PSPI0          BIT 0BEH     ; SPI0 PRIORITY
PT2            BIT 0BDH     ; TIMER 2 PRIORITY
PS0            BIT 0BCH     ; UART0 PRIORITY
;PT1            BIT 0BBH     ; TIMER 1 PRIORITY
;PX1            BIT 0BAH     ; EXTERNAL INTERRUPT 1 PRIORITY
;PT0            BIT 0B9H     ; TIMER 0 PRIORITY
;PX0            BIT 0B8H     ; EXTERNAL INTERRUPT 0 PRIORITY
MASTER         BIT 0C7H     ; SMBUS 0 MASTER/SLAVE
TXMODE         BIT 0C6H     ; SMBUS 0 TRANSMIT MODE
STA            BIT 0C5H     ; SMBUS 0 START FLAG
STO            BIT 0C4H     ; SMBUS 0 STOP FLAG
ACKRQ          BIT 0C3H     ; SMBUS 0 ACKNOWLEDGE REQUEST
ARBLOST        BIT 0C2H     ; SMBUS 0 ARBITRATION LOST
ACK            BIT 0C1H     ; SMBUS 0 ACKNOWLEDGE FLAG
SI             BIT 0C0H     ; SMBUS 0 INTERRUPT PENDING FLAG
TF2H           BIT 0CFH     ; TIMER 2 HIGH BYTE OVERFLOW FLAG
TF2L           BIT 0CEH     ; TIMER 2 LOW BYTE OVERFLOW FLAG
TF2LEN         BIT 0CDH     ; TIMER 2 LOW BYTE INTERRUPT ENABLE
TF2CEN         BIT 0CCH     ; TIMER 2 LFO CAPTURE ENABLE
T2SPLIT        BIT 0CBH     ; TIMER 2 SPLIT MODE ENABLE
TR2            BIT 0CAH     ; TIMER 2 ON/OFF CONTROL
T2XCLK         BIT 0C8H     ; TIMER 2 EXTERNAL CLOCK SELECT
;CY             BIT 0D7H     ; CARRY FLAG
;AC             BIT 0D6H     ; AUXILIARY CARRY FLAG
;F0             BIT 0D5H     ; USER FLAG 0
;RS1            BIT 0D4H     ; REGISTER BANK SELECT 1
;RS0            BIT 0D3H     ; REGISTER BANK SELECT 0
;OV             BIT 0D2H     ; OVERFLOW FLAG
F1             BIT 0D1H     ; USER FLAG 1
;P              BIT 0D0H     ; ACCUMULATOR PARITY FLAG
CF             BIT 0DFH     ; PCA 0 COUNTER OVERFLOW FLAG
CR             BIT 0DEH     ; PCA 0 COUNTER RUN CONTROL BIT
CCF2           BIT 0DAH     ; PCA 0 MODULE 2 INTERRUPT FLAG
CCF1           BIT 0D9H     ; PCA 0 MODULE 1 INTERRUPT FLAG
CCF0           BIT 0D8H     ; PCA 0 MODULE 0 INTERRUPT FLAG
                            ; ADC 0 WINDOW INTERRUPT FLAG
; ADC0CN 0E8H
AD0EN          BIT 0EFH     ; ADC 0 ENABLE
AD0TM          BIT 0EEH     ; ADC 0 TRACK MODE
AD0INT         BIT 0EDH     ; ADC 0 EOC INTERRUPT FLAG
AD0BUSY        BIT 0ECH     ; ADC 0 BUSY FLAG
AD0WINT        BIT 0EBH     ; ADC 0 WINDOW INTERRUPT FLAG
AD0CM2         BIT 0EAH     ; ADC 0 CONVERT START MODE BIT 2
AD0CM1         BIT 0E9H     ; ADC 0 CONVERT START MODE BIT 1
AD0CM0         BIT 0E8H     ; ADC 0 CONVERT START MODE BIT 0
SPIF           BIT 0FFH     ; SPI 0 INTERRUPT FLAG
WCOL           BIT 0FEH     ; SPI 0 WRITE COLLISION FLAG
MODF           BIT 0FDH     ; SPI 0 MODE FAULT FLAG
RXOVRN         BIT 0FCH     ; SPI 0 RX OVERRUN FLAG
NSSMD1         BIT 0FBH     ; SPI 0 SLAVE SELECT MODE 1
NSSMD0         BIT 0FAH     ; SPI 0 SLAVE SELECT MODE 0
TXBMT          BIT 0F9H     ; SPI 0 TX BUFFER EMPTY FLAG
SPIEN          BIT 0F8H     ; SPI 0 SPI ENABLE
打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 相关推荐
  • 805

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分