1
\$\begingroup\$

Every time I try to program my hex file I get an error:

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x3b
configuration memory
program memory
Address: 0 Expected Value: 25 Received Value: 0
Failed to program device

Even my asm code BUILD SUCCESSFUL, I still get an error and can't program any code.

Do you know where is the problem?

I am using Pickit3 with ICD2 PIC10F222 microcontroller. MPLAB X IDE/IPE v5.15

Code:

;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC10F222. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files Required: P10F222.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************

list p=10F222 ; list directive to define processor
#include p10F222.inc ; processor specific variable definitions

__CONFIG _MCLRE_ON&_CP_OFF&_WDT_OFF&_MCPU_OFF&_IOFSCS_4MHZ 


;***** VARIABLE DEFINITIONS
TEMP_VAR UDATA
temp1 RES 1 ;DELAY REGISTER1
temp2 RES 1 ;DELAY REGISTER2 
temp3 RES 1 ;DELAY REGISTER3 
temp4 RES 1 ;DELAY REGISTER4 
temp5 RES 1 ;TIMING REGISTER
temp6 RES 1 ;TINING REGISTER



;**********************************************************************
RESET_VECTOR CODE 0xFF ; processor reset vector

; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.

MAIN CODE 0x000
movwf OSCCAL ; update register with factory cal value


INITIALIZE
MOVLW B'0010' 
TRIS GPIO ; INITIALIZE
CLRF ADCON0 ; ADC DISABLE
CLRF GPIO
MOVLW B'00001000'
OPTION ; ENABLE GPIO2 AS A DIGITAL PORT
CLRF GPIO



START:

SCAN1:
BTFSS GPIO,1
GOTO SCAN1
ENSURE:
BTFSC GPIO,1
GOTO ENSURE
CALL LOOP1
COUNTDOWN:
MOVLW 0xFF
MOVWF temp5
MOVLW 0xFF
MOVWF temp6
COUNTDOWN2:
BTFSC GPIO,1
GOTO RELAYACTIVATE
DECFSZ temp5
GOTO COUNTDOWN2
MOVLW 0xFF
MOVWF temp5
DECFSZ temp6
GOTO COUNTDOWN2
GOTO SCAN1

RELAYACTIVATE:
BSF GPIO,0
CALL LOOP1
CALL LOOP1
CALL LOOP1
SCAN2:
BTFSS GPIO,1
GOTO SCAN2
ENSURE2:
BTFSC GPIO,1
GOTO ENSURE2
CALL LOOP1
COUNTDOWN3:
MOVLW 0xFF
MOVWF temp5
MOVLW 0xFF
MOVWF temp6
COUNTDOWN4:
BTFSC GPIO,1
GOTO RELAYDEACTIVATE
DECFSZ temp5
GOTO COUNTDOWN4
MOVLW 0xFF
MOVWF temp5
DECFSZ temp6
GOTO COUNTDOWN4
GOTO SCAN2

RELAYDEACTIVATE:
BCF GPIO,0
RESET

LOOP1:
MOVLW 0x00 
MOVWF temp1
MOVLW 0xF0
MOVWF temp2

LOOP2:
DECFSZ temp1
GOTO LOOP2
DECFSZ temp2
GOTO LOOP2
return


END

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

\$\endgroup\$
  • \$\begingroup\$ Next time, use the "Code Sample" button to nicely format your code. \$\endgroup\$ – Long Pham Feb 26 '19 at 16:07
  • \$\begingroup\$ Edited to use "code sample" thanks. \$\endgroup\$ – karka Slapta Feb 26 '19 at 16:42
  • 1
    \$\begingroup\$ "Failed to program device" suggests that PICKIT 3 doesn't see your chip. Am not familiar with your 40-pin socket interface: is your chip inserted into the right place? Are its jumpers configured correctly? \$\endgroup\$ – glen_geek Feb 26 '19 at 16:52
  • 2
    \$\begingroup\$ Looks to me like "PIC10EX" is possibly correct. However, note that the chip goes in backwards: your photo shows the chip rotated 180 degrees. \$\endgroup\$ – glen_geek Feb 26 '19 at 17:23
  • 3
    \$\begingroup\$ karka: If you've found a solution to your question, consider posting an answer (below). It is encouraged on this site, and it may help others in your situation. \$\endgroup\$ – glen_geek Feb 27 '19 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.