1 Востаннє редагувалося Ярослав (15.04.2016 16:55:38)

Тема: Підключення списку із адресами SFR для контролера 8051

Вітаю, форумчани!

Намагаюсь запрограмувати C8051F310 контролер з допомогою Simplicity Studio.

Ось код:

Прихований текст

$NOMOD51
;-----------------------------------------------------------------------------
; F31x_Blinky.asm Rickey's World
;-----------------------------------------------------------------------------
; Copyright 2014 Silicon Laboratories, Inc.
; http:;www.silabs.com
;
; Program Description:
;
; This program flashes the green LED on the C8051F33x target board about
; five times a second using a simple while loop in assembly.
;
;
; How To Test:
;
; 1) Ensure shorting blocks are place on the following:
;    - J3: P3.3_LED
;    - J8: Power - 9V or Debugger
; 2) Connect the USB Debug Adapter to J4. If 9V power is selected on J8,
;    connect the 9V power adapter to P1.
; 3) Compile and download code to the C8051F310-TB development board by selecting
;        Run -> Debug from the menus, clicking the Debug button in the quick menu,
;        or pressing F11.
; 4) Run the code by selecting Run -> Resume from the menus, clicking the
;        Resume button in the quick menu, or pressing F8.
;
;
; Target:         C8051F310
; Tool chain:     Silicon Labs Studio / Keil C51 9.51
; Command Line:   None
;
; Release 1.1 (BL)
;        - Updated Description / How to Test
;        - 16 JAN 2014
;
; Release 1.0
;    - Initial Revision (HF)
;    - 04 FEB 2003
;

$include (SI_C8051F310_Defs.inc)

;-----------------------------------------------------------------------------
; EQUATES
;-----------------------------------------------------------------------------

GREEN_LED   equ   P3.3                    ; Green LED: '1' is ON
PWMPIN      EQU   P1.0                    ; PWM output pin
PWM_FLAG    EQU   0                       ; Flag to indicate high/low signal



;-----------------------------------------------------------------------------
; RESET and INTERRUPT VECTORS
;-----------------------------------------------------------------------------

            ; Reset Vector
            cseg AT 0
            ljmp Main                     ; Locate a jump to the start of
                                          ; code at the reset vector.

            ; Interrupt Vector (Timer 0)
            cseg AT 000Bh
            ljmp TIMER_0_INTERRUPT        ; Locate a jump to the start of
                                          ; timer 0 subroutine on the interrupt

;-----------------------------------------------------------------------------
; CODE SEGMENT
;-----------------------------------------------------------------------------


Blink       segment  CODE

            rseg     Blink                ; Switch to this code segment.
            using    0                    ; Specify register bank for the
                                          ; following program code.

Main:
            ; Disable the WDT.
            anl   PCA0MD, #NOT(040h)      ; clear Watchdog Enable bit

            ; Enable the Port I/O Crossbar
            orl   P0SKIP, #04h            ; skip LED pin in crossbar
                                          ; assignments
            mov   XBR1, #40h              ; enable Crossbar
            orl   P3MDOUT, #08h           ; make LED pin output push-pull
            orl   P3MDIN, #08h            ; make LED pin input mode digital

            ; Set up PWM
            MOV TMOD,#00H ; Timer0 in Mode 0
            MOV R7, #160    ; Set pulse width control
            ; The value loaded in R7 is value X as
            ; discussed above.
            SETB EA ; Enable Interrupts
            SETB ET0 ; Enable Timer 0 Interrupt
            SETB TR0 ; Start Timer

            ; Initialize LED to OFF
            clr   GREEN_LED

            ; Simple delay loop.
Loop2:      mov   R7, #03h           
Loop1:      mov   R6, #00h
Loop0:      mov   R5, #00h
            djnz  R5, $
            djnz  R6, Loop0
            djnz  R7, Loop1
            cpl   GREEN_LED               ; Toggle LED.
            jmp   Loop2

TIMER_0_INTERRUPT:
        JB PWM_FLAG, HIGH_DONE    ; If PWM_FLAG flag is set then we just finished
                    ; the high section of the
    LOW_DONE:            ; cycle so Jump to HIGH_DONE
        SETB PWM_FLAG        ; Make PWM_FLAG=1 to indicate start of high section
        SETB PWMPIN        ; Make PWM output pin High
        MOV TH0, R7        ; Load high byte of timer with R7
                    ; (pulse width control value)
        CLR TF0            ; Clear the Timer 0 interrupt flag
        RETI            ; Return from Interrupt to where
                    ; the program came from
    HIGH_DONE:
        CLR PWM_FLAG        ; Make PWM_FLAG=0 to indicate start of low section
        CLR PWMPIN        ; Make PWM output pin low
        MOV A, #0FFH        ; Move FFH (255) to A
        CLR C            ; Clear C (the carry bit) so it does
                    ; not affect the subtraction
        SUBB A, R7        ; Subtract R7 from A. A = 255 - R7.
        MOV TH0, A        ; so the value loaded into TH0 + R7 = 255
        CLR TF0            ; Clear the Timer 0 interrupt flag
        RETI            ; Return from Interrupt to where
                    ; the program came from

PWM_STOP:
        CLR TR0            ; Stop timer to stop PWM
        RET

;-----------------------------------------------------------------------------
; End of file.

END

Компілятор видає помилку:

                        413                 SETB EA ; Enable Interrupts

*** _____________________________________________^

*** ERROR #A45 IN 413 (D:\8051\F31x_Blinky_asm_2\src\F31x_Blinky.asm, LINE 94): UNDEFINED SYMBOL

Я знайшов таке рішення http://www.keil.com/support/docs/982.htm. Поставив галочку Define SFR names в налаштуваннях асемблеру. Пробував різні асемблери - A51, AX51, однак проект все одно не компілюється.

Поки я визначу адреси вручну, однак набагато зручніше було б працювати із попередньо визначеними адресами. Можете, будь ласка, порадити що-небудь?

Post's attachments

cant_include_sfr_definitions.png 36.31 kb, 249 downloads since 2016-04-15 

2

Re: Підключення списку із адресами SFR для контролера 8051

По-перше покажіть вміст файлу "SI_C8051F310_Defs.inc", а по-друге визначте що змінюється в аргументах командного рядка до асемблера, коли ви ставите галочку "Define SFR names" в налаштуваннях асемблеру. Чому ви вирішили що константа EA існує?

3

Re: Підключення списку із адресами SFR для контролера 8051

$NOMOD51

вимикає попередньо визначені SFR для 8051

Подякували: leofun012

4

Re: Підключення списку із адресами SFR для контролера 8051

0xDADA11C7 дуже дякую!