PICDEM Mechatronics

Find out how to setup your programmer's software and how to solve many common problems.

Moderator: phalanx

Post Reply
LadyInRed
Posts: 3
Joined: Fri Apr 04, 2014 2:25 am

PICDEM Mechatronics

Post by LadyInRed » Tue Jul 22, 2014 5:14 am

Hi,

I have a development board from Microchip - PICDEM Mechatronics.
I am new in pic microcontroller programming and i try to learn testing the projects from Microchip.
I use MPLAB IDE V8.70 and PIC16F917.

In this moment i try to test Project 2 - DuskIndicator, but i receive an error.

Debug build of project `C:\Users\mircea\Desktop\Projects\Project2\DuskIndicator.mcp' started.
Language tool versions: pic32-as.exe v1.12, pic32-gcc.exe v1.12, pic32-ld.exe v1.12, pic32-ar.exe v1.12
Preprocessor symbol `__DEBUG' is defined.
Tue Jul 22 14:33:55 2014
----------------------------------------------------------------------
Build aborted. The project contains no source files.
----------------------------------------------------------------------
Debug build of project `C:\Users\mircea\Desktop\Projects\Project2\DuskIndicator.mcp' failed.
Language tool versions: pic32-as.exe v1.12, pic32-gcc.exe v1.12, pic32-ld.exe v1.12, pic32-ar.exe v1.12
Preprocessor symbol `__DEBUG' is defined.
Tue Jul 22 14:33:55 2014
----------------------------------------------------------------------
BUILD FAILED


Please, i need help.
Thank you.

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: PICDEM Mechatronics

Post by waltr » Tue Jul 22, 2014 9:21 am

Read the HELP in MPLAB for the IDE and any of the other pieces needed. The Help in MPLAB is quite good and useful (un-like typical Microsoft help).
You have not:
1- Added source files to the project
2- selected the correct PIC
3- setup the tools
4- selected the correct tool chain
5- and probably some other things

LadyInRed
Posts: 3
Joined: Fri Apr 04, 2014 2:25 am

Re: PICDEM Mechatronics

Post by LadyInRed » Wed Jul 23, 2014 6:43 am

Hi,

I use MPASM assembler v5.41, yes i have selected the PIC16F917 microcontroller.
Active tools is Miccrochip MPASM Toolsuite.
Know i receive the next error :

"Make: The target "C:\Users\mircea\Desktop\Projects\Demo project 1\16F917TMPO.o" is out of date. Executing: "C:\Program Files (x86)\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F917 "16F917TMPO.ASM" /l"16F917TMPO.lst" /e"16F917TMPO.err" /o"16F917TMPO.o" /d__DEBUG=1 Error[150] C:\USERS\MIRCEA\DESKTOP\PROJECTS\DEMO PROJECT 1\16F917TMPO.ASM 12 : Labels must be defined in a code or data section when making an object file Halting build on first failure as requested.
"


I have read in the documentation this :

"150 Labels must be defined in a code or data section when making an object file
When generating a linkable object file, all data and code address labels must be
defined inside a data or code section. Symbols defined by the equ and set directives
can be defined outside of a section.
"

What i supposed to do ?

And look at my code :

Code: Select all

 
; PROCESSOR DECLARATION
;------------------------------------------------------------------------------
       LIST P=16F917 ; list directive to define processor
       #INCLUDE <P16F917.INC> ; processor specific variable definitions

;------------------------------------------------------------------------------
; MAIN PROGRAM
;------------------------------------------------------------------------------
       START
; Notes: 
; This project reads a tactile switch input.
; On every button push RD7 is toggled from a 1 to a 0 or vice-versa. 
; 
; Connections:
; RA0 to a SW2
; RD7 to a D0 (left most LED) 
; 
;************************************************************************************

       __CONFIG _CP_OFF & _CPD_OFF & _BOD_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _FCMEN_OFF & _IESO_OFF

       errorlevel -302 

#define SW2 PORTA,0
#define LED PORTD,7

       cblock 0x20
         Temp
       endc
;************************************************************************************
       org 0x00
       goto Initialize
       org 0x05
;************************************************************************************
; Initialize - Initialize comparators, internal oscillator, I/O pins, 
; analog pins, variables 
;
;************************************************************************************
Initialize  
       bsf STATUS,RP0               ; we'll set up the bank 1 Special Function Registers first
       bcf TRISD,7                     ; RD7 is an output
       bsf TRISA,0                     ; RA0 is an input
       movlw b'01110000'           ; 8Mhz
       movwf OSCCON
       movlw b'10000110'           ; PORTB pull-up disabled, TMR0 Prescaler 1:128
       movwf OPTION_REG 
       movlw 0x07
       movwf CMCON0                 ; turn off comparators
; Turn off Analog 
       clrf ANSEL
       bcf STATUS,RP0 ; go back to bank 0
       bcf LED ; clear the LED
;************************************************************************************
; Main - When SW2 is pressed, the LED is toggled, and the debounce routine for SW2 is
; initiated. Debouncing a switch is necessary to prevent one button press from 
; being read as more than one button press by the microcontroller. A 
; microcontroller can read a button so fast that contact jitter in the switch 
; may be interpreted as more than one button press.
;
;************************************************************************************
Main
       btfsc SW2            ; Loop here until Switch 2 is pressed (SW2 is defined in the include file)
       goto Main
; Once Switch 2 is pressed, toggle the LED on or off
        movlw 0x80         ; Exclusive ORing PORTD with 0x80 will effectively
        xorwf PORTD,f      ; toggle RD7 on and off
DebounceState1           ; Wait here until SW2 is released
        btfss SW2
goto DebounceState1
        clrf TMR0              ; Once released clear TMR0 and the TMR0 interrupt flag
        bcf INTCON,T0IF    ; in preparation to time 16ms
DebounceState2            ; State2 makes sure than SW2 is unpressed for 16ms before
        btfss SW2            ; returning to look for the next time SW2 is pressed
        goto DebounceState1        ; If SW2 is pressed again in this state then return to State1
        btfss INTCON,T0IF             ; Else, continue to count down 16ms
        goto DebounceState2      ; Time = TMR0_max * TMR0 prescaler * (1/(Fosc/4)) = 256*128*0.5E-6 = 16.4ms
goto Main
END ; directive 'end of program'
Thank you for your interest.

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: PICDEM Mechatronics

Post by waltr » Wed Jul 23, 2014 9:34 am

FYI: Use the Code Tags when posting code so the formatting is not destroyed and we can count line numbers.

This is the error that needs fixing:
Error[150] C:\USERS\MIRCEA\DESKTOP\PROJECTS\DEMO PROJECT 1\16F917TMPO.ASM 12 : Labels must be defined in a code or data section when making an object file Halting build on first failure as requested.
This says that the label on line 12 of the 16F917TMPO.ASM file has not been defined.
Not sure which line in the code you posted this is since line counting is not making sense. My guess is it is the _CONFIG statement that the assembler is choking on. Are you sure the assembler know where the include file (#INCLUDE <P16F917.INC> is located?
You can try coping that file to the local folder where the .asm file is located. If this works then you just need to setup the 'paths' to the include files in MPLAB.

This error could also be due to lack of 'indents'. Like here:

Code: Select all

cblock 0x20
Temp
endc
The variable 'Temp' must be indented else the assembler thinks it is a label.

Do carefully study other code examples. Most of the ones found in the Microchip App Notes show good formatting and also look at code posted on the Microchip user's forum. Also do read more of the MPLAB Help Topics, these are very good and there are tutorials in there on the assembler. Assembly coding is not hard to learn but it is very picky and some things must be perfectly correct.

Post Reply