• 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.

Got my p16Pro

Status
Not open for further replies.

Squintz

New Member
I got my programmer and its fully assembled. And i went to the store and baught the parts to connect it to my variable power supply and i got some solder type protoboards. Now all i need is for micro to deliver my sample pics i ordered last wednesday.

About how long did it take for you guys to receiver your free samples?

Also i notice that the pic programer uses a DC plug but it says it accepts ac and dc. What is the polarity of the DC? is it Positive or negative center?
 

Exo

Active Member
took about 2 weeks for me...

but this is belgium... once it reaches the postal offices here things get really slow :lol:
 

Kane2oo2

New Member
you need a program which turns that assembler code into a hex format which can be programmed into the chip.

the most well known is MPLAB which can be found at the microchip webiste and is free

:D

Kane
 

Camping

New Member
Open your files in a project. Then at a node. Then tell wich PIC you have and then you BUILD ALL. And then you see in your work space a HEX.

Cya
 

isaacj

New Member
squintz said:
Also i notice that the pic programer uses a DC plug but it says it accepts ac and dc. What is the polarity of the DC? is it Positive or negative center?
It does not matter. The plug connects to the rectifier bridge, so whichever plug configuration you use the programmer will still work.

while waiting from a responce from you guys i ound PicALLw software
the picallw software was written by the guy that designed the programmer. His software is not free, if you want to use a PIC other than the F84 you'll have to register your software. A free programmer that works with the p16pro is icprog. The settings to make the software work with your programmer are here.
 

Squintz

New Member
ok... Got the IC-Prog and installed it. And i have the following code.

Code:
 org 0x00                     ;This is where we come on power up and reset

 ;*******************SETUP CONSTANTS*******************

INTCON           EQU 0x0B       ;Interrupt Control Register

PORTB            EQU 0x06       ;Port B register address

PORTA            EQU 0x05       ;Port A register address

TRISA              EQU 0x85       ;TrisA register address

TRISB              EQU 0x86       ;TrisB register address

STATUS          EQU 0X03      ;Status register address

          COUNT          EQU 0x0c         ;This will be our counting variable 

 TEMP              EQU 0x0d      ;Temporary store for w register

  goto    main                                     ;Jump over the interrupt address

 
;***************INTERRUPT ROUTINE***************

  org                  0x04                ;This is where PC points on an interrupt

  movwf            TEMP              ;Store the value of w temporarily 

 incf                  COUNT,1       ;Increment COUNT by 1, and put the result

                                                 ;back into COUNT 

 movlw 0x0A                           ;Move the value 10 into w

 subwf              COUNT,0       ;Subtract w from COUNT, and put the

                                                ;result in w

 btfss                STATUS,0       ;Check the Carry flag. It will be set if 

                                                ;COUNT is equal to, or is greater than w,

                                                ;and will be set as a result of the subwf

                                                ;instruction

 

 goto                carry_on           ;If COUNT is <10, then we can carry on

 goto                clear                 ;If COUNT is >9, then we need to clear it

 

carry_on

 bcf                  INTCON,0x01 ;We need to clear this flag to enable

                                                 ;more interrupts

 movfw            TEMP              ;Restore w to the value before the interrupt

  retfie                                      ;Come out of the interrupt routine

 
clear

 clrf                  COUNT          ;Set COUNT back to 0

 bcf                  INTCON,1      ;We need to clear this flag to enable

                                                ;more interrupts 

retfie                                       ;Come out of the interrupt routine

  

;*******************Main Program*********************

 main

 ;*******************Set Up The Interrupt Registers****

 bsf                   INTCON,7      ;GIE – Global interrupt enable (1=enable)

 bsf                   INTCON,4      ;INTE - RB0 Interrupt Enable (1=enable)

 bcf                  INTCON,1      ;INTF - Clear FLag Bit Just In Case

 ;*******************Set Up The Ports******************

  bsf                STATUS,5     ;Switch to Bank 1

 movlw 0x01            

 movwf TRISB                      ;Set RB0 as input 

 movlw 0x10                        

 movwf TRISA                      ;Set R 0 to RA3 on PortA as output

  bcf                  STATUS,5  ;Come back to Bank 0

 ;*******************Now Send The Value Of COUNT To Port A            

 loop

movf                 COUNT,0       ;Move the contents of Count into W

movwf              PORTA           ;Now move it to Port A

goto                 loop                 ;Keep on doing this

 end                                           ;End Of Program
now do i put that code into an text file and save it as "FILE.asm" and then goto open file? When i do that it ask me if i want to swap bits.

Can someone please explain what i do once im in the program. I have already setup the prog as the link above said to. and i'v picked that im going to be programming a pic16f84a. Whats the next few steps? When i first chose my PIC that i was going to be programming the window filled up with all kinds of HEX? What is all that Hex code for. Do i delete this hex?
 

Exo

Active Member
First go to MPLAB IDE

Choose 'Project' - 'New' to create a new project
give it a name and a destination folder

Then choose 'project' - 'add files to project' and add your file.asm to the project

then choose 'project' - 'build all' to compile your file (turn it into machine code HEX file)

The now produced hex file (if you have no errors) is the one you need to open with ICPROG
 

Squintz

New Member
Code:
;*******************SETUP CONSTANTS*******************

INTCON EQU 0x0B ;Interrupt Control Register
PORTB EQU 0x06 ;Port B register address
PORTA EQU 0x05 ;Port A register address
TRISA EQU 0x85 ;TrisA register address
TRISB EQU 0x86 ;TrisB register address
STATUS EQU 0X03 ;Status register address
COUNT EQU 0x0c ;This will be our counting variable 
TEMP EQU 0x0d ;Temporary store for w register
goto main ;Jump over the interrupt address

;***************INTERRUPT ROUTINE***************
org 0x04 ;This is where PC points on an interrupt
movwf TEMP ;Store the value of w temporarily 
incf COUNT,1 ;Increment COUNT by 1, and put the result
;back into COUNT 
movlw 0x0A ;Move the value 10 into w
subwf COUNT,0 ;Subtract w from COUNT, and put the
;result in w
btfss STATUS,0 ;Check the Carry flag. It will be set if 
;COUNT is equal to, or is greater than w,
;and will be set as a result of the subwf
;instruction
goto carry_on ;If COUNT is <10, then we can carry on
goto clear ;If COUNT is >9, then we need to clear it
carry_on
bcf INTCON,0x01 ;We need to clear this flag to enable
;more interrupts
movfw TEMP ;Restore w to the value before the interrupt
retfie ;Come out of the interrupt routine

clear
clrf COUNT ;Set COUNT back to 0
bcf INTCON,1 ;We need to clear this flag to enable
;more interrupts 
retfie ;Come out of the interrupt routine
;*******************Main Program*********************
main
;*******************Set Up The Interrupt Registers****
bsf INTCON,7 ;GIE – Global interrupt enable (1=enable)
bsf INTCON,4 ;INTE - RB0 Interrupt Enable (1=enable)
bcf INTCON,1 ;INTF - Clear FLag Bit Just In Case
;*******************Set Up The Ports******************
bsf STATUS,5 ;Switch to Bank 1
movlw 0x01 
movwf TRISB ;Set RB0 as input 
movlw 0x10 
movwf TRISA ;Set R 0 to RA3 on PortA as output
bcf STATUS,5 ;Come back to Bank 0
;*******************Now Send The Value Of COUNT To Port A 
loop
movf COUNT,0 ;Move the contents of Count into W
movwf PORTA ;Now move it to Port A
goto loop ;Keep on doing this
end ;End Of Program
Code:
Deleting intermediary files... done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A "LED.asm" /l"LED.lst" /e"LED.err"
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 11 : Found opcode in column 1. (goto)
Warning[205] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 14 : Found directive in column 1. (org)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 15 : Found opcode in column 1. (movwf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 16 : Found opcode in column 1. (incf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 18 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 19 : Found opcode in column 1. (subwf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 21 : Found opcode in column 1. (btfss)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 25 : Found opcode in column 1. (goto)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 26 : Found opcode in column 1. (goto)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 28 : Found opcode in column 1. (bcf)
Warning[204] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 30 : Found pseudo-op in column 1. (movfw)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 31 : Found opcode in column 1. (retfie)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 34 : Found opcode in column 1. (clrf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 35 : Found opcode in column 1. (bcf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 37 : Found opcode in column 1. (retfie)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 41 : Found opcode in column 1. (bsf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 42 : Found opcode in column 1. (bsf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 43 : Found opcode in column 1. (bcf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 45 : Found opcode in column 1. (bsf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 46 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 47 : Found opcode in column 1. (movwf)
Message[302] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 47 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 48 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 49 : Found opcode in column 1. (movwf)
Message[302] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 49 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 50 : Found opcode in column 1. (bcf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 53 : Found opcode in column 1. (movf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 54 : Found opcode in column 1. (movwf)
Warning[203] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 55 : Found opcode in column 1. (goto)
Warning[205] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 56 : Found directive in column 1. (end)
Loaded C:\Documents and Settings\Owner\My Documents\PICs\LED.COD
BUILD SUCCEEDED: Fri Oct 24 18:53:04 2003
Why all the errors.... I got this code right from a web site and tryed to convert it into hex with MPLab and no luck!
 

Exo

Active Member
They're warnings, not errors (the build succeeded, see the last line)

Microchips assembler persists that you nicely format your file...
Put labels at the beginning of a line, and code after some tabs, and so on

like this

Code:
    ORG 0x00
    goto main 

Main
    org 0x04 
    movwf TEMP 
    incf COUNT,1 
    ...
    ...
    End
It is meant to make your code more readable and easyer to understand
... You got to admit, the code you posted looks like quite a mess without format
 

Squintz

New Member
Code:
Deleting intermediary files... done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A "LED.asm" /l"LED.lst" /e"LED.err"
Message[302] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 47 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\PICS\LED.ASM 49 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Loaded C:\Documents and Settings\Owner\My Documents\PICs\LED.COD
BUILD SUCCEEDED: Fri Oct 24 20:23:46 2003
Now all i get is this? What does it mean?
 

Exo

Active Member
Bank selection messages, you'll get them all the time, even when code is correct..

ignore them or add ERRORLEVEL -302 to the top of your code
 

Exo

Active Member
i can't see any clear wdt commands in the code so no, disable the watchdog. Otherwise the pic will reset in the middle of the program because the watchdog timer overflows
 

Squintz

New Member
Im using picall now because the IC Pic does not work on my computer. The pic call pops up a message when i try and burn the chip.
Code:
Program error:

Program adress=000 buffer=2811 device=3fff
when i first load the HEX file i get the message:

Code:
Warning:

Configuration word is not
included with the hex file !!!

For detail look at the PICALLW.HLP section FAQ!!!
What is the configuration code? I looked at the Help file but did not understand it! Thank you all for helping me through all this
 

damonwill

New Member
Same problem

I have the same problem. I can program a chip once, and then when I erase it and re-program it gives me the first error message. Any thoughts?

:evil:
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Squintz said:
What is the configuration code? I looked at the Help file but did not understand it! Thank you all for helping me through all this
The configuration word sets the various configuration options for the processor - oscillator type, WDT, code protection and various others depending on the particular PIC. It's essential to set these correctly, and it's advisable to do so in the source code so it's included in the HEX file. Not doing this results in the warning message you got, which essentially is prompting you to set them in PicAll before programming the chip.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top