Hi all
I am a beginner an try to understand PIC microcontrollers, especially PIC12F629.
So I wrote a simple program, which should do nothing else than create a square wave signal from one output to the next. except GPIO,3 which can be only an input.
here is the asm file:
;************************************************* *********************
; This file is a basic code template for object module code *
; generation on the PICmicro PIC12F629. This file contains the *
; basic code building blocks to build upon. As a project minimum *
; the 12F629.lkr file will also be required for this file to *
; correctly build. The .lkr files are located in the MPLAB *
; directory. *
; *
; If interrupts are not used all code presented between the *
; code section "INT_VECTOR and code section "MAIN" can be removed. *
; In addition the variable assignments for 'w_temp' and *
; 'status_temp' can be removed. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler and linker (Document DS33014). *
; *
; Refer to the respective PICmicro data sheet for additional *
; information on the instruction set. *
; *
;************************************************* *********************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;************************************************* *********************
; *
; Files required: *
; 12F629.lkr *
; *
; *
;************************************************* *********************
; *
; Notes: *
; *
; *
; *
; *
;************************************************* *********************
list p=12F629 ; list directive to define processor
#include <p12F629.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.
;***** VARIABLE DEFINITIONS (examples)
; example of using Shared Uninitialized Data Section
gpio equ 0x05
mc equ 0x22
;************************************************* *********************
org 0x000 ; processor reset vector
; isr code can go here or be located as a call subroutine elsewhere
; these first 4 instructions are not required if the internal oscillator is not used
main
call 0x3FF ; retrieve factory calibration value
bsf STATUS,RP0 ; set file register bank to 1
movwf OSCCAL ; update register with factory cal value
bcf STATUS,RP0 ; set file register bank to 0
; remaining code goes here
movlw b'000001000'
tris gpio
begin bsf gpio,0
call p
bcf gpio,0
call p
bsf gpio,1
call p
bcf gpio,1
call p
bsf gpio,2
call p
bcf gpio,2
call p
bsf gpio,4
call p
bcf gpio,4
call p
bsf gpio,5
call p
bcf gpio,5
call p
goto begin
p movlw 0xa9
movwf mc
dec decfsz mc,f
goto dec
return
; initialize eeprom locations
;EE CODE 0x2100
; DE 0x00, 0x01, 0x02, 0x03
END ; directive 'end of program'
************************************************** ***************************************
At least I got signals,which can be seen in the attachment.
The settings off the configuration bits were:
osc internal no clockout
watchdog timer off
power up timer on
master clear enable internal
brown out detect off
code protect off
data ee read protect off
why is there a signal on GPIO,3-this should be a input only?
and why is no square wave signal on GPIO,5 - this output is permanently high?
can anybody help me
thanks in advance
gustav47
Bookmarks