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.

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

PIC Christmas Light Project

Status
Not open for further replies.

3v0

Coop Build Coordinator
Forum Supporter
amdkicksass said:
Any particular place i should buy the stuff from ? Maybe straight from microchip ?

pete

You can order direct from Microchip. But that limits your order to what they have.

Mouser carries the Pickit2 and I suspect that Newark does too. Newark has very good prices on PIC processors and most semiconductors. Mouser is better on connectors.
 
The PickIt2 comes in different packages, one being the starter kit. I believe the starter kit (DV164120), comes with a card that has a socket for the PIC. If i dont go with the starter kit , are there other socket cards/zif socket cards that would be better ?

pete
 

3v0

Coop Build Coordinator
Forum Supporter
amdkicksass said:
The PickIt2 comes in different packages, one being the starter kit. I believe the starter kit (DV164120), comes with a card that has a socket for the PIC. If i dont go with the starter kit , are there other socket cards/zif socket cards that would be better ?

I have been doing some digging. It seems that PicKit2 supports a limited number of PICs. The selection from the 14 bit processors is said to be fair. This may or may not be a problem for you. There is a README somewhere that lists supported processors.

The starter kit comes with the low pin count demo board. Works with chps up to 20 pins. This is an OK choice. For larger PICs ICSP is the way to go anyway.

Most often PICs are programed IN CIRCUIT using 3 signal pins plus power and gnd. Serveral different types of connectors are currently being used to do this. The Pickit2 has a 6 pin .1 pitch connector. It looks like it may take a standard header pin setup.

Many of the DIY setups including the Inchworm are using a standard 2x5 pin header. Olimex uses a Molex 6 pin. The original ICD2 uses a modular (RJ11 IIRC).

When you build your target board you need to provide an ICSP connector that connects to the Pickit2.
 
Thanks for the suggestions, i will have the stuff ordered from Newark hopefully by the end of the day today. I think the starter kit should be sufficient. I started working on the code and i have few questions that someone can hopefully answer.

Here is what i have after a few tutorials and some fiddling around.

Code:
;PIC Christmas Pattern Lights
;Peter 2007

	LIST	p=16F628		;tell assembler what chip we are using
	#include "P16F628.inc"		;include the defaults for the chip
	__config 0x3D18			;sets the configuration settings 
					;(oscillator type etc.)

;Constants 
COUNT1           equ       020h          ;First counter for our delay loops
Timer1           equ       021h          ;Second counter for our delay loops 
                



        org	0x0000		        ;org sets the origin, 0x0000 for the 16F628,
    			        	;this is where the program starts running	
	movlw	0x07
	movwf	CMCON			;turn comparators off (make it like a 16F84)

   	bsf 	STATUS,		RP0	;select bank 1
   	movlw 	b'00000000'		;set PortB all outputs
   	movwf 	TRISB
        movlw 	b'00000000'
	movwf	TRISA			;set PortA all outputs
	bcf	STATUS,		RP0	;select bank 0
               
        movlw  255                  ;First put the value of 85h in the W register
        movwf  020h                  ;Now move it to our 08h register. 
        movlw  85h                  ;First put the value of 85h in the W register
        movwf  020h                  ;Now move it to our 08h register. 
             
               
Main

Pat1         MOVLW 01H                      ; Set the first bit
               MOVWF PORTB                    ; on Port B.
               RLF PORTB,1                    ;Pattern to shift Lights left
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTB,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               RLF PORTA,1
               CALL Delay
               
               RRF PORTA,1                                 ;Pattern to shift Lights Right
               CALL Delay
               RRF PORTA,1
               CALL Delay
               RRF PORTA,1
               CALL Delay
               RRF PORTA,1
               CALL Delay
               RRF PORTA,1
               CALL Delay
               RRF PORTA,1
               CALL Delay
               RRF PORTA,1
               CALL Delay
               RRF PORTA,1
               CALL Delay
               
               
Rpt           decfsz Timer1,1                              ;This second loop keeps the LED
               goto Pat1
               goto end
               
               
                            
Delay

Loop1             decfsz              COUNT1,F     ;This second loop keeps the LED
                     goto                 Loop1              ;turned off long enough for us to
                    
return

The first thing that interests me is that the MPLAB software like to complain about much more things in general than other software. For example when i try to build/assemble this code MPLAB it gives me these errors, while assembly thru PIC sim IDE gives no errors.

Code:
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F628 "christmaslights1.asm" /l"christmaslights1.lst" /e"christmaslights1.err"
Message[302] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 21 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 23 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Warning[202] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 26 : Argument out of range.  Least significant bits used.
Error[113]   C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 89 : Symbol not previously defined (end)
Warning[203] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 98 : Found opcode in column 1. (return)
Warning[205] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 101 : Found directive in column 1. (end)
Error[173]   C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 102 : Source file path exceeds 62 characters (C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM)
Halting build on first failure as requested.
BUILD FAILED: Thu Jun 21 22:10:35 2007

I have been able to get the code to run the PIC sim IDE and after it gets tot he delay subroutine it pretty much hangs and goes into an endless loop, any ideas there.

Thanks
pete
 

Gayan Soyza

Active Member
To work with RLF/RRF you need to know about CARRY bit in STATUS register for the time being simple method can do in your main routine like this

Code:
Right	movlw	01h
	movwf	PORTB
	call	Delay
	movlw	02h
	movwf	PORTB
	call	Delay
	movlw	04h
	movwf	PORTB
	call	Delay
	movlw	08h
	movwf	PORTB
	call	Delay
	movlw	10h
	movwf	PORTB
	call	Delay
	movlw	20h
	movwf	PORTB
	call	Delay
	movlw	40h
	movwf	PORTB
	call	Delay
	movlw	80h
	movwf	PORTB
	call	Delay
	goto	Right

And the delay should like this. Remove the 4 lines that moved 255 to both registers in your program

Code:
Delay	decfsz	20h,F
	goto	Delay
	decfsz	21h,F
	goto	Delay
	return
 
If I remove the lines that store the value 255 in both registers that what would the
decfsz 20h,F
command do, how would it react if there is nothing in that register ?
Also since the value in that register is being modified by decreasing it how is it supposed to be used again and again if after the first delay run the register is already run down to 0 ?

Pete
 

Nigel Goodwin

Super Moderator
Most Helpful Member
amdkicksass said:
If I remove the lines that store the value 255 in both registers that what would the
decfsz 20h,F
command do, how would it react if there is nothing in that register ?

It can't have 'nothing' in the register, it can only have a decimal value between 0 and 255 - if it's zero the register will loop round and decrement to 255.

I also strongly advise you don't just use register numbers, use an equ to give it a name at the top of the program - using numbers is just confusing.

Also since the value in that register is being modified by decreasing it how is it supposed to be used again and again if after the first delay run the register is already run down to 0 ?

See above, decrementing 0 moves to 255.
 
Thanks for all the suggestions, i am currently trying to mess with everything i.e simulations, assembly stuff and transferring things to the chip.
Currently one annoyance is that when simulating things with PIC simulator IDE, things don't move at real time speed. Even when speed is at normal, things move extremely slow. I have to calculate delays and then flash them on the chip to see the time it actually takes ,which is extremely time consuming. Is their a way to have it simulate the program exactly the same way the PIC would ?

Thanks
pete
 
Status
Not open for further replies.

Latest threads

Top