Hello,
Im trying to program a PIC16F628, but when set any pin on high, they output 4,5V (VDD) for a few seconds (random) and then drop down to 2V.
I have tryd this with 2 of these PIC's and both have the same problem.
Code (Hi-tech compiler):
Assembly spewed out by the compiler
The chip is connected to 4.5V and ground, and MCLR is directly connected to the according pin. (Did not work with pullup resistor).
The code seems to work, but the output voltage is just weird.
Does anyone have any solutions?
Thanks in advance.
Im trying to program a PIC16F628, but when set any pin on high, they output 4,5V (VDD) for a few seconds (random) and then drop down to 2V.
I have tryd this with 2 of these PIC's and both have the same problem.
Code (Hi-tech compiler):
Code:
#include <pic.h>
#include <htc.h>
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000
#endif
__CONFIG(0x3F38);
void main(){
TRISA=0b00000000;
PORTA=0b11111111;
TRISB=0b00000000;
PORTB=0b11111111;
while(1){
}
}
Assembly spewed out by the compiler
Code:
opt subtitle "HI-TECH Software Omniscient Code Generator (Lite mode) build 7503"
opt pagewidth 120
opt lm
processor 16F628
clrc macro
bcf 3,0
endm
clrz macro
bcf 3,2
endm
setc macro
bsf 3,0
endm
setz macro
bsf 3,2
endm
skipc macro
btfss 3,0
endm
skipz macro
btfss 3,2
endm
skipnc macro
btfsc 3,0
endm
skipnz macro
btfsc 3,2
endm
indf equ 0
indf0 equ 0
pc equ 2
pcl equ 2
status equ 3
fsr equ 4
fsr0 equ 4
c equ 1
z equ 0
pclath equ 10
# 9 "C:\Users\Robin\Desktop\LightProject\TimeController\main.c"
psect config,class=CONFIG,delta=2 ;#
# 9 "C:\Users\Robin\Desktop\LightProject\TimeController\main.c"
dw 0x3F70 ;#
FNROOT _main
global _cycle1
global _cycle2
global _CMCON
psect maintext,global,class=CODE,delta=2
global __pmaintext
__pmaintext:
_CMCON set 31
global _PORTA
_PORTA set 5
global _PORTB
_PORTB set 6
global _RA0
_RA0 set 40
global _RA1
_RA1 set 41
global _RA3
_RA3 set 43
global _RA4
_RA4 set 44
global _TRISA
_TRISA set 133
global _TRISB
_TRISB set 134
file "TimeController.as"
line #
psect cinit,class=CODE,delta=2
global start_initialization
start_initialization:
psect bssCOMMON,class=COMMON,space=1
global __pbssCOMMON
__pbssCOMMON:
_cycle1:
ds 2
_cycle2:
ds 2
; Clear objects allocated to COMMON
psect cinit,class=CODE,delta=2
clrf ((__pbssCOMMON)+0)&07Fh
clrf ((__pbssCOMMON)+1)&07Fh
clrf ((__pbssCOMMON)+2)&07Fh
clrf ((__pbssCOMMON)+3)&07Fh
psect cinit,class=CODE,delta=2
global end_of_initialization
;End of C runtime variable initialization code
end_of_initialization:
clrf status
ljmp _main ;jump to C main() function
psect cstackCOMMON,class=COMMON,space=1
global __pcstackCOMMON
__pcstackCOMMON:
global ?_main
?_main: ; 0 bytes @ 0x0
global ??_main
??_main: ; 0 bytes @ 0x0
;;Data sizes: Strings 0, constant 0, data 0, bss 4, persistent 0 stack 0
;;Auto spaces: Size Autos Used
;; COMMON 14 0 4
;; BANK0 80 0 0
;; BANK1 80 0 0
;; BANK2 48 0 0
;;
;; Pointer list with targets:
;;
;; Critical Paths under _main in COMMON
;;
;; None.
;;
;; Critical Paths under _main in BANK0
;;
;; None.
;;
;; Critical Paths under _main in BANK1
;;
;; None.
;;
;; Critical Paths under _main in BANK2
;;
;; None.
;;
;;Main: autosize = 0, tempsize = 0, incstack = 0, save=0
;;
;;
;;Call Graph Tables:
;;
;; ---------------------------------------------------------------------------------
;; (Depth) Function Calls Base Space Used Autos Params Refs
;; ---------------------------------------------------------------------------------
;; (0) _main 0 0 0 0
;; ---------------------------------------------------------------------------------
;; Estimated maximum stack depth 0
;; ---------------------------------------------------------------------------------
;; Call Graph Graphs:
;; _main (ROOT)
;;
;; Address spaces:
;;Name Size Autos Total Cost Usage
;;BITCOMMON E 0 0 0 0.0%
;;EEDATA 80 0 0 0 0.0%
;;NULL 0 0 0 0 0.0%
;;CODE 0 0 0 0 0.0%
;;COMMON E 0 4 1 28.6%
;;BITSFR0 0 0 0 1 0.0%
;;SFR0 0 0 0 1 0.0%
;;BITSFR1 0 0 0 2 0.0%
;;SFR1 0 0 0 2 0.0%
;;STACK 0 0 0 2 0.0%
;;BANK0 50 0 0 3 0.0%
;;BITSFR3 0 0 0 4 0.0%
;;SFR3 0 0 0 4 0.0%
;;ABS 0 0 4 4 0.0%
;;BITBANK0 50 0 0 5 0.0%
;;BITSFR2 0 0 0 5 0.0%
;;SFR2 0 0 0 5 0.0%
;;BITBANK1 50 0 0 6 0.0%
;;BANK1 50 0 0 7 0.0%
;;BITBANK2 30 0 0 8 0.0%
;;BANK2 30 0 0 9 0.0%
;;DATA 0 0 4 10 0.0%
global _main
psect maintext
;; *************** function _main *****************
;; Defined at:
;; line 13 in file "C:\Users\Robin\Desktop\LightProject\TimeController\main.c"
;; Parameters: Size Location Type
;; None
;; Auto vars: Size Location Type
;; None
;; Return value: Size Location Type
;; None void
;; Registers used:
;; wreg, status,2
;; Tracked objects:
;; On entry : 17F/0
;; On exit : 0/0
;; Unchanged: 0/0
;; Data sizes: COMMON BANK0 BANK1 BANK2
;; Params: 0 0 0 0
;; Locals: 0 0 0 0
;; Temps: 0 0 0 0
;; Totals: 0 0 0 0
;;Total ram usage: 0 bytes
;; This function calls:
;; Nothing
;; This function is called by:
;; Startup code after reset
;; This function uses a non-reentrant model
;;
psect maintext
file "C:\Users\Robin\Desktop\LightProject\TimeController\main.c"
line 13
global __size_of_main
__size_of_main equ __end_of_main-_main
_main:
opt stack 8
; Regs used in _main: [wreg+status,2]
line 14
l1232:
;main.c: 14: CMCON = 0x7;
movlw (07h)
bcf status, 5 ;RP0=0, select bank0
bcf status, 6 ;RP1=0, select bank0
movwf (31) ;volatile
line 15
l1234:
;main.c: 15: TRISA=0b00000000;
bsf status, 5 ;RP0=1, select bank1
bcf status, 6 ;RP1=0, select bank1
clrf (133)^080h ;volatile
line 16
l1236:
;main.c: 16: PORTA=0b11111111;
movlw (0FFh)
bcf status, 5 ;RP0=0, select bank0
bcf status, 6 ;RP1=0, select bank0
movwf (5) ;volatile
line 17
;main.c: 17: TRISB=0b00000000;
bsf status, 5 ;RP0=1, select bank1
bcf status, 6 ;RP1=0, select bank1
clrf (134)^080h ;volatile
line 18
l1238:
;main.c: 18: PORTB=0b11111111;
movlw (0FFh)
bcf status, 5 ;RP0=0, select bank0
bcf status, 6 ;RP1=0, select bank0
movwf (6) ;volatile
goto l795
line 20
;main.c: 20: while(1){
l794:
line 24
l795:
line 20
goto l795
l796:
line 25
l797:
global start
ljmp start
opt stack 0
GLOBAL __end_of_main
__end_of_main:
;; =============== function _main ends ============
signat _main,88
psect maintext
global btemp
btemp set 07Eh
DABS 1,126,2 ;btemp
global wtemp0
wtemp0 set btemp
end
The chip is connected to 4.5V and ground, and MCLR is directly connected to the according pin. (Did not work with pullup resistor).
The code seems to work, but the output voltage is just weird.
Does anyone have any solutions?
Thanks in advance.
Last edited: