Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hey (MPLAB SIMULATOR )

Status
Not open for further replies.
You need to forget about the OSCCAL value for a minute! Thats at 0x3FF right at the top of the chip... Its only used to tune the 4mhz internal osc anyway.

The ID locations are at 0x2000/1/2/3,, But what MPLAB is telling you is the CHIP id (microchips id for all pics) should be 0xF80 for a PIC12F629, but your chip has a 0 in this location OR it's not reading the chip correctly. Is there any chance this chip could have been zapped with static? do you have any more to try!

I get a similar error when I've blown one up..

Ian
 
Please tell me if the ICSP connection in the picture i sent is good for PIC12F?

I will be doing the same connections for the PIC16F627A. Please advise if other connections are required.

I also am not sure about connecting the ICSPCLK to the ICSPCLK of the PIC. is that k?

Should i use an XT oscillator with caps at the CLKIN/CLKOUT.?Please help.
 
The connection to the pic was fine it should have worked, Do you need an external clock? why not use the internal clock.. I know the external clock can be 10mhz, is this why you want the external clock? There should be enough capacitance in the breadboard to leave them off the crystal., if not put the smallest needed @ 10pf .

Ian
 
Queries

Hey,

The datasheet says that FFh is the last memory of Bank 1 of the Data Memory of PIC12F629. Then where is 3FFh? Program Memory?

In an effort to find out the OSCCAL value at 3FF, I tried to read the PIC12F's stored memory by pressing the read button of my PICKIT2 software (not using MPLAB). But there is no 3ffh register and all the value it is reading is 3FFF. I have also attached the screendump of the situation. please help.

I am planning to set the configuration bits in the code itself. Can you please check my code? it is attached. The new code lines are about setting the oscillator config bits.

MPLAB is still flagging error saying that Device ID is not matching even though I bought a new PIC12F629 from microchip.

Thanks in advance,
 

Attachments

  • flashLED.zip
    9.2 KB · Views: 137
  • No 3FF in program memory.pdf
    127.8 KB · Views: 200
I also thought that this osccal issue was because of my erasing the device but now I think otherwise.

I was also asked by the PICKIT2 Programmer S/w to use the 'export hex file' so that the configuration bits will be included. Can you please help check if this is good? I have attached the screen dump.
 

Attachments

  • export file screen.pdf
    98.6 KB · Views: 207
oh yes, but I was planning to use the 16F incase the 12F doesnt work at all. So, right now, I am on the 12F.

To reply to your question, no i havent tried the 16F yet.. please let me know if the code is k.

Do i need to power the Vdd separately from a 5V supply?

The device id errors still persist.. please help ..
 
do i have to download a firmware to the pic? there is such an option in PICKIT2 programmer software-->Tools---> Download the PICKIT operating software.
 
But Ian, this is a new one I just got from Microchip. I just dont know why the new and the old one of PIC 12F doesnt work...

Much thanks to you and all who helped.
 
Last edited:
From the pickit 2 device support list, PIC12F508, 509, 510, 519 these are the PIC12 devices that are supported :) Hope this helps
 
Hi everyone

when I tried to simulated in mplabsim appeared it this mistake

CORE-E0002: Stack under flow error occurred from instruction at 0x00002a

If someone could help me please!!!!

Thanks!!


Code is here

list P=16F84A
include<P16F84A.inc>
cblock 0x0C
segundo_uni
segundo_dec
unidad
decena
centena
unidmil
digito1 ;minutos
digito2 ;munutos
digito3 ;hora
digito4 ;hora
digito5
digito6
alar_digito1; digito alarma minuto
alar_digito2; digito alarma minuto
alar_digito3; digito alarma hora
alar_digito4; digito alarma hora
contador
segundo
contador_interupcion ; controla la sincronizacion del reloj
controlador_interupcion; se encarga de controlar las interupciones
controlador_cambio;
contador_alarma
activar ; controlar la sincronizacion del reloj
timbre_alarma
endc

org 2
goto inicio
return
org 4
goto contador
return

inicio ;configuracion de pines
bsf STATUS, RP0
movlw b'01110000'
movwf PORTB
movlw b'11110000'
movwf PORTA
movlw b'10100000'
movwf INTCON
movlw b'00000011'
movwf OPTION_REG
bcf STATUS,RP0
clrf segundo_uni
clrf segundo_dec
clrf unidad
clrf decena
clrf centena
clrf unidmil
clrf contador
clrf segundo
clrf activar
clrf contador_interupcion
clrf controlador_interupcion
clrf controlador_cambio
clrf digito6
clrf digito5
clrf timbre_alarma
movlw d'0'
movwf TMR0
;inicializacion de los digitos del display
clrf digito4
clrf digito3
clrf digito2
clrf digito1
clrf alar_digito4
clrf alar_digito2
clrf alar_digito3
movlw d'1'
movwf alar_digito1
clrf contador_alarma
return visualizar

; contador de segundos unidad
contador_unidad_segundo
incf segundo_uni
movfw segundo_uni
sublw d'10'
btfsc STATUS,Z
call contador_decena_segundo
movfw segundo_uni
movwf digito5
call visualizar
return
; contador de segundos decena
contador_decena_segundo
clrf segundo_uni
clrf digito5
incf segundo_dec
movfw segundo_dec
sublw d'6'
btfsc STATUS,Z
call contador_unidad_minuto
movfw segundo_dec
movwf digito6
call visualizar
return
;contador de unidades minuto
contador_unidad_minuto
clrf segundo_dec
clrf digito6
incf unidad
movf unidad,w
sublw d'10'
btfsc STATUS,Z
call contador_decena_minuto
movf unidad,w
movwf digito1
; es hora de alarma
movfw centena
subwf alar_digito3,0
btfsc STATUS,Z
call activar_alarma
return
call visualizar
return
;contador de decena minuto
contador_decena_minuto
clrf unidad
clrf digito1
incf decena
movf decena,w
sublw d'6'
btfsc STATUS,Z
call contador_unidad_hora
movf decena,w
movwf digito2
; es hora de alarma
movfw centena
subwf alar_digito3,0
btfsc STATUS,Z
call activar_alarma
return
call visualizar
return
;contador de unidad hora
contador_unidad_hora
clrf decena
clrf digito2
incrementar_hora
incf centena
movf centena,w
sublw d'10'
btfsc STATUS,Z
call contador_decena_hora
movf centena,w
movwf digito3
movfw centena
sublw d'4'
btfss STATUS,Z
call visualizar
incf contador,1
movfw contador
sublw d'3'
btfss STATUS,Z
call visualizar
clrf digito3
clrf digito4
clrf centena
clrf unidmil
clrf contador
call visualizar
return
;contador de decena hora
contador_decena_hora
clrf centena
clrf digito3
incf unidmil
movf unidmil,w
sublw d'10'
btfsc STATUS,Z
clrf unidmil
movf unidmil,w
movwf digito4
call visualizar
return
visualizar
movfw digito1
bcf PORTA,1 ;DESHABILTAR DECENAS
bcf PORTA,2 ;DESHABILTAR CENTENAS
bcf PORTA,3 ;DESHABILTAR UNIDAD DE MILLAR
movwf PORTB
bsf PORTA,0 ; HABILITAR UNIDADES
movfw digito2
bcf PORTA,0; DESHABILITAS UNIDADES
movwf PORTB
bsf PORTA,1; HABILITAS DECENAS
movfw digito3
bcf PORTA,1; DESHABILITAS DECENAS
movwf PORTB
bsf PORTA,2 ; HABILITO CENTENAS
movfw digito4
bcf PORTA,2 ;DESHABILITO CENTENAS
movwf PORTB
bsf PORTA,3 ; HABILITO UNIDAD DE MILLAR
btfsc PORTB,4
goto stop; detener el tiempo
movfw controlador_interupcion
sublw d'5'
btfsc STATUS,Z
goto activar_interupcion
goto visualizar

controlador ; se encarga de controlar la ocurenncia de un segundo
bsf INTCON,7
bcf INTCON,2
movlw d'0'
movwf TMR0
incf segundo
movfw segundo
sublw d'243'
btfss STATUS,Z
call visualizar
clrf segundo
call contador_unidad_segundo
return
return

stop
bcf INTCON,7 ; deshabilitas cualquier tipo de interupcion
btfsc PORTB,4
call continuamos_stop
return
activar_interupcion
bsf INTCON,7
bcf INTCON,2
movlw d'0'
movwf TMR0
clrf activar
clrf contador_interupcion
clrf controlador_interupcion
clrf controlador_cambio
goto visualizar

continuamos_stop
movlw d'5'
movwf controlador_interupcion ; activamos el controlador
btfsc PORTB,5
goto pre_controlador
call RETARDO_10MS
btfsc PORTB,5
goto pre_controlador
incf contador_interupcion
cambio
bucle
btfss PORTB,5
goto bucle
call RETARDO_10MS
btfss PORTB,5
goto bucle
sigue
movlw d'5'
movwf activar; activamos que se produjo un intento de camibo de horairo
movfw contador_interupcion
sublw d'6' ;;
btfsc STATUS,Z
call special
movfw contador_interupcion
sublw d'1'
btfsc STATUS,Z ; horas?
goto pre_incrementar_hora
movfw contador_interupcion
sublw d'2'
btfsc STATUS,Z ; minutos?
goto pre_incrementar_minuto
movfw contador_interupcion
sublw d'3'
btfsc STATUS,Z ; mostrar alarma?
goto visualizar_especial
movfw contador_interupcion
sublw d'4'
btfsc STATUS,Z ; horas_alarma?
goto pre_incrementar_hora_alarma
movfw contador_interupcion
sublw d'5'
btfsc STATUS,Z ; minutos_alaram?
goto pre_incrementar_minuto_alarma

special
movlw d'1'
movwf contador_interupcion
return
pre_controlador
movfw activar
sublw d'5'
btfss STATUS, Z
goto visualizar
goto sigue

pre_incrementar_hora ; espera que se pulse para incrementar
btfsc PORTB,6
goto visualizar
call RETARDO_10MS
btfsc PORTB,6
goto visualizar
bucle2
btfss PORTB,6
goto bucle2
goto incrementar_hora

pre_incrementar_minuto; espera que se pulse para incrementar
btfsc PORTB,6
goto visualizar
call RETARDO_10MS
btfsc PORTB,6
goto visualizar
return
bulce3
btfss PORTB,6
goto bulce3
goto contador_unidad_minuto

visualizar_especial
movfw alar_digito1
bcf PORTA,1 ;DESHABILTAR DECENAS
bcf PORTA,2 ;DESHABILTAR CENTENAS
bcf PORTA,3 ;DESHABILTAR UNIDAD DE MILLAR
movwf PORTB
bsf PORTA,0 ; HABILITAR UNIDADES
movfw alar_digito2
bcf PORTA,0; DESHABILITAS UNIDADES
movwf PORTB
bsf PORTA,1; HABILITAS DECENAS
movfw alar_digito3
bcf PORTA,1; DESHABILITAS DECENAS
movwf PORTB
bsf PORTA,2 ; HABILITO CENTENAS
movfw alar_digito4
bcf PORTA,2 ;DESHABILITO CENTENAS
movwf PORTB
bsf PORTA,3 ; HABILITO UNIDAD DE MILLAR
btfsc PORTB,4
goto stop; detener el tiempo
movfw controlador_interupcion
sublw d'5'
btfsc STATUS,Z
goto activar_interupcion
goto visualizar_especial

;contador de unidades minuto alarma
contador_unidad_minuto_alarma
incf alar_digito1
movf alar_digito1,w
sublw d'10'
btfsc STATUS,Z
call contador_decena_minuto_alarma
call visualizar_especial
return
return

;contador de decena minuto
contador_decena_minuto_alarma
clrf alar_digito1
incf alar_digito2
movf alar_digito2,w
sublw d'6'
btfsc STATUS,Z
call contador_unidad_hora_alarma
call visualizar_especial
return
return

;contador de unidad hora
contador_unidad_hora_alarma
clrf alar_digito2
incrementar_hora_alarma
incf alar_digito3
movf alar_digito3,w
sublw d'10'
btfsc STATUS,Z
call contador_decena_hora_alarma
movfw alar_digito3
sublw d'4'
btfss STATUS,Z
call visualizar_especial
incf contador_alarma,1
movfw contador_alarma
sublw d'3'
btfss STATUS,Z
call visualizar_especial
clrf alar_digito3
clrf alar_digito4
clrf contador_alarma
call visualizar_especial
return
;contador de decena hora
contador_decena_hora_alarma
clrf alar_digito3
incf alar_digito4
movf alar_digito4,w
sublw d'10'
btfsc STATUS,Z
clrf alar_digito4
call visualizar_especial
return
pre_incrementar_hora_alarma ; espera que se pulse para incrementar
btfsc PORTB,6
goto visualizar_especial
call RETARDO_10MS
btfsc PORTB,6
goto visualizar_especial
bucle4
btfss PORTB,6
goto bucle4
goto incrementar_hora_alarma

pre_incrementar_minuto_alarma; espera que se pulse para incrementar
btfsc PORTB,6
goto visualizar_especial
call RETARDO_10MS
btfsc PORTB,6
goto visualizar_especial
return
bulce5
btfss PORTB,6
goto bulce5
goto contador_unidad_minuto_alarma

activar_alarma
movfw unidmil
subwf alar_digito4,0
btfss STATUS,Z
return
movfw decena
subwf alar_digito2,0
btfss STATUS,Z
return
movfw unidad
subwf alar_digito1,0
btfss STATUS,Z
return
bcf INTCON,7; deshabilitado todo tipo de interupcion
bsf PORTB,7
call RETARDO_20S
call RETARDO_5S
bcf PORTB,7
call RETARDO_1S
bsf PORTB,7
call RETARDO_20S
call RETARDO_5S
bcf PORTB,7
call RETARDO_1S
bsf PORTB,7
call RETARDO_5S
call RETARDO_2S
bcf INTCON,2
bsf INTCON,7
movlw d'0'
movwf TMR0
goto contador_unidad_minuto
return
return
return

include<RETARDOS.inc>
END
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top