![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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? |
|
|
|
|
|
|
(permalink) |
|
took about 2 weeks for me...
but this is belgium... once it reaches the postal offices here things get really slow :lol: |
|
|
|
|
|
|
(permalink) |
|
OK i got the PIC16pro and i got my PIC16f84a i built a circuit shown here:
http://www.mstracey.btinternet.co.uk.../progtut12.htm Now i want to take the code from that site and program my PIC What software do i need? Please give free ones and links are good! |
|
|
|
|
|
|
(permalink) |
|
Well while waiting from a responce from you guys i ound PicALLw software but still i dont know what to do with it. How do i take the program from the above site and get it into my PIC.
|
|
|
|
|
|
|
(permalink) |
|
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 Kane |
|
|
|
|
|
|
(permalink) |
|
OK i got MPLab and installed it. How do i use it?
|
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) | ||
|
Quote:
Quote:
__________________
If this is not what you expected, please alter your expectations. |
|||
|
|
|
|
|
(permalink) |
|
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
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? |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
Finally!...Thank you so much. This is just the steps i needed
|
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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
... You got to admit, the code you posted looks like quite a mess without format |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|