Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Can u help me to convert my C programm to hex code for PIC microcontroler..?????

Status
Not open for further replies.
At least your recent steps remedied the two issues I pointed out.

Now there are new issues.

Please post the contents of MTXV4.INC?

The Assembly Code in written in a relocatable fashion, we'll need to a a linker script.

Find the file 16F628_g.lkr which is found in the LKR subdirectory in the MPASM Suite directory.

Example Location:
C:\Program Files\Microchip\MPASM Suite\LKR

Add it to the project by right click on the Project Window on the Linker Script directory icon and selecting "Add Files..."

Then rebuild the project.

BigDog
 
its the content of mtxv4.inc

;**********************************************************************
; *
; Filename: mtxv4.inc *
; Date: *
; File Version: *
;
; *
;**********************************************************************
; Notes:
;
; RF transmitter prot.v4 (Manchester)
;**********************************************************************

EXTERN mtx_buffer, mtx_delay
EXTERN mtx_init, mtx_send

- - - Updated - - -

added the 16f628_g.lkr.....but still its not working...got an error message like
Debug build of project `C:\Users\PRAMOD\Desktop\HEX files\servo1.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Fri Jun 15 19:29:59 2012
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Users\PRAMOD\Desktop\HEX files\enc-044.o".
Clean Warning: File "C:\Users\PRAMOD\Desktop\HEX files\C:\Users\PRAMOD\Desktop\important\8758\enc-044.lst" doesn't exist.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F628 "C:\Users\PRAMOD\Desktop\important\8758\enc-044.asm" /l"enc-044.lst" /e"enc-044.err" /o"enc-044.o" /d__DEBUG=1
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 59 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 61 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 63 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 65 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 84 : Use of this instruction is not recommended.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 91 : Use of this instruction is not recommended.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 101 : Use of this instruction is not recommended.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 125 : Use of this instruction is not recommended.
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" "..\..\..\..\Program Files\Microchip\MPASM Suite\LKR\16f628_g.lkr" "enc-044.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"servo1.cof" /M"servo1.map" /W
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - could not find definition of symbol 'mtx_buffer' in file './enc-044.o'.
Errors : 1

Link step failed.
----------------------------------------------------------------------
Debug build of project `C:\Users\PRAMOD\Desktop\HEX files\servo1.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Fri Jun 15 19:30:00 2012
----------------------------------------------------------------------
BUILD FAILED

- - - Updated - - -

its the print screen images.....

MPLAB.jpgMPLAB2.jpg
 

Looks like we maybe missing another file. Were there any other files besides the two you've added to the project?

It appears there is a library file missing, I'll need to review the code to determine the exact issue.

At least you are down to a single error:

Error - could not find definition of symbol 'mtx_buffer' in file './enc-044.o'.

BigDog
 
ya..there is one more file......

;**********************************************************************
; *
; Filename: mtxv4.asm *
; Date: *
; File Version: *
; *
; *
;**********************************************************************
; Notes:
;
; RF transmitter prot.v4.2 (Manchester)
;**********************************************************************
;
; header : 20xbit1, 1xbit0
; bytes : 8xbitX, 1xbit1, 1xbit0
;
; packet structure: <data0> <data1> <data2> <checksum>
;
; 020 - library version
; untested!
;
; 021 - add half frame variable
; remove buffer initialization
;
; 030-20050102 codec-v4.2:
; checksum with CRC-8
; T=350 usec
; 3-byte buffer length
;
;**********************************************************************

;define TXINV
;invert TX output so inactive is HIGH?

list p=16F628
#include <p16F628.inc>

txbit EQU 0x01
txport EQU PORTA

#ifndef TXINV
#define TXLOW 0
#define TXHIGH txbit
#else
#define TXLOW txbit
#define TXHIGH 0
#endif

GLOBAL mtx_buffer, mtx_init, mtx_send, mtx_delay

packet_len EQU 2

;***** VARIABLE DEFINITIONS
mtxdata UDATA

count1 res 1
count2 res 1
ncnt res 1
bt res 1
sum res 1
mtx_buffer res 2

mtx_delay res 1 ; half_frame delay

;**********************************************************************

mtx CODE

mtx_init movlw .117 ; 350 usec
movwf mtx_delay
return
;

mtx_send
; send out buffer
outbuf movlw 0x14 ; 20xbit1, 1xbit0

header movwf count2
head0 call bit1
decfsz count2,F
goto head0
call bit0

movlw mtx_buffer
movwf FSR
movlw packet_len
movwf count1
movlw 0xff
movwf sum
;
outbu0 movf INDF,W
call update_sum
movf INDF,W
call outbyte
incf FSR,F
decfsz count1,F
goto outbu0
movf sum,W
call outbyte
; buffer is sent

return

update_sum ; fast CRC-8 algorithm with poly x^8+x^5+x^4+1
; executes in 23 cycles per update

xorwf sum,f
clrw
btfsc sum,7
xorlw 0x7a
btfsc sum,6
xorlw 0x3d
btfsc sum,5
xorlw 0x86
btfsc sum,4
xorlw 0x43
btfsc sum,3
xorlw 0xb9
btfsc sum,2
xorlw 0xc4
btfsc sum,1
xorlw 0x62
btfsc sum,0
xorlw 0x31
movwf sum
return
;
outbyte movwf bt
movlw 8
movwf count2
outby0 rlf bt,F
btfsc STATUS,C
goto outby1
call bit0
goto outby2
outby1 call bit1
outby2 decfsz count2,F
goto outby0
;
call bit1
; and bit0

bit0 movlw TXHIGH ; HIGH
movwf txport

ndelaya0 movf mtx_delay, W
movwf ncnt
ndelaya1 decfsz ncnt, F
goto ndelaya1

movlw TXLOW ; to LOW transition
movwf txport

ndelayb0 movf mtx_delay, W
movwf ncnt
ndelayb1 decfsz ncnt, F
goto ndelayb1

return

bit1 movlw TXLOW ; LOW
movwf txport

ndelayc0 movf mtx_delay, W
movwf ncnt
ndelayc1 decfsz ncnt, F
goto ndelayc1

movlw TXHIGH ; to HIGH transition
movwf txport

ndelaye0 movf mtx_delay, W
movwf ncnt
ndelaye1 decfsz ncnt, F
goto ndelaye1

return

end

when i added this to the project..........SUCCEFUL....... we done:)

----------------------------------------------------------------------
Debug build of project `C:\Users\PRAMOD\Desktop\HEX files\servo1.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Fri Jun 15 20:06:46 2012
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Users\PRAMOD\Desktop\HEX files\enc-044.o".
Clean Warning: File "C:\Users\PRAMOD\Desktop\HEX files\C:\Users\PRAMOD\Desktop\important\8758\enc-044.lst" doesn't exist.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F628 "C:\Users\PRAMOD\Desktop\important\8758\enc-044.asm" /l"enc-044.lst" /e"enc-044.err" /o"enc-044.o" /d__DEBUG=1
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 59 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 61 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 63 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 65 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 84 : Use of this instruction is not recommended.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 91 : Use of this instruction is not recommended.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 101 : Use of this instruction is not recommended.
Warning[224] C:\USERS\PRAMOD\DESKTOP\IMPORTANT\8758\ENC-044.ASM 125 : Use of this instruction is not recommended.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F628 "C:\Users\PRAMOD\Desktop\important\16f628\mtxv4.asm" /l"mtxv4.lst" /e"mtxv4.err" /o"mtxv4.o" /d__DEBUG=1
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" "..\..\..\..\Program Files\Microchip\MPASM Suite\LKR\16f628_g.lkr" "enc-044.o" "mtxv4.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"servo1.cof" /M"servo1.map" /W
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Errors : 0

MP2HEX 4.20, COFF to HEX File Converter
Copyright (c) 2008 Microchip Technology Inc.
Errors : 0

Loaded C:\Users\PRAMOD\Desktop\HEX files\servo1.cof.
----------------------------------------------------------------------
Debug build of project `C:\Users\PRAMOD\Desktop\HEX files\servo1.mcp' succeeded.
Preprocessor symbol `__DEBUG' is defined.
Fri Jun 15 20:06:48 2012
----------------------------------------------------------------------
BUILD SUCCEEDED


...thank u...thank u very much..im not sure abt wheather the code is working or not...but i got the hex file....:)
 


thank u sir....btw in our first program,thats the servo.c.....there is only two positions are available for the servo motor,but i need a center postion too,,..what change i want to make in that programm for that???
 

I'm not sure I understand your requirements. I've reviewed the code and it appears to be a light tracking routine based on the input of two LDRs to control a servo.

The servo position should be proportionally based on the difference of inputs from the two LDRs with a predefined minimum and maximum servo positions.


BigDog
 

ya,...u r right...i need something like a center position for the servo when the two LDRs are in equal postion....i mean when the resistance from the two LDRs are same....
 

A servo typically has what is referred to as an "Idle Position" which corresponds to a pulse width half way between the minimum and maximum pulse widths.

In your case the minimum is 1ms and the maximum 2ms pulse width with a 20ms cycle period, therefore the "Idle Position" should correspond to be 1.5ms.

BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top