+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 19

Thread: Twinkle twinkle little star...

  1. #1
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default Twinkle twinkle little star...

    Hi Folks. I'm back to square one. Naturally, when I loaded my program it did not work, so I have to work in circuit, that requires a lot of switching chips around, and I'm thinking of getting a PICKIT2 programmer, and a set up like FUTZ has.

    Anyway, I wrote a program to flash the LED, and it doesn't work, so I don't know why, since it does work on SIM, no problem. I'm using a 16F88. I left some of the set up files since I need them to run the complete program and want to write these test programs around them.

    Code:
    		
    	LIST	p=16F88
    	include "P16F88.inc"
    	__config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON & _LVP_OFF 
    
     errorlevel	-302
    
    
    	Cblock	0x20
    	TIMER1, TIMER2, HBYTE, LBYTE,
    	endc
    	
    	
    
       	banksel	TRISA		;bank 1
    	movlw	0x42		;1MHz clock
    	movwf	OSCCON
    	movlw	0x07		;turn comparators off
    	movwf	CMCON
    
    	movlw	B'11111111'
    	movwf	TRISB		
    	movlw	B'00000010'	
    	movwf	ANSEL
    	movwf	TRISA
    	movlw	B'00000000'
    	movwf	OPTION_REG	
    	banksel	PORTA
    	clrf	HBYTE
    	clrf	LBYTE
    	clrf	PORTA
     	goto	start
    
    
    delay
    	movlw   D'150'          
       	movwf   TIMER1          
                   
    delay2
    	movlw	D'150'			
    	movwf	TIMER2
    	decfsz  TIMER2,F        
    	goto    $-1             
                   
    	decfsz	TIMER1,F		
    	goto	delay2				
    	return			
    
    start 
     	movlw	0xA
    	movwf	LBYTE
    	movlw	0x2
    	movwf	HBYTE
    
    
    	
    loop2
       	bsf		PORTA,6        
    	bsf		PORTA,7
    
    
    	call	delay
    	call	delay
    	clrf	PORTA       
    	call 	delay
    	call	delay
                  
    
    	decfsz	LBYTE,F
    	goto	loop2
    	decfsz	HBYTE,F
    	goto	loop2
    
     
    	end
    


  2. #2
    futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent
    Join Date
    Sep 2007
    Location
    Vancouver, B.C.
    Posts
    1,980

    Default

    Quote Originally Posted by RobertD View Post
    Hi Folks. I'm back to square one. Naturally, when I loaded my program it did not work, so I have to work in circuit, that requires a lot of switching chips around, and I'm thinking of getting a PICKIT2 programmer, and a set up like FUTZ has.
    Aint nothing like the real thing. You're finally coming to your senses. The sim is a fine tool for some things, but the breadboard is the only way to really know if something is going to work.

    And ICSP is the only way to get things done at the experimentation stage. Jacking chips in and out takes forever, and wears the pins out too.
    =========================
    Futz's Microcontrollers & Robotics
    =========================

  3. #3
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    I'm learning...

  4. #4
    jpanhalt Excellent jpanhalt Excellent jpanhalt Excellent jpanhalt Excellent jpanhalt Excellent jpanhalt Excellent
    Join Date
    Jun 2006
    Location
    Cleveland, OH, USA
    Posts
    1,589

    Default

    Agree with above, but there is a simple alternative to ICSP, just adapt a ZIF to your breadboard.

    John

  5. #5
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    Default

    Robert, your Junebug works just like the PICkit2, what are you hoping the PICkit2 will offer that's different?

    PS the 18F1320 is a pretty decent PIC and offers a few advantages over the 16F88. One is a built in A/D acquisition timer, much less if any bank switching and an extended instruction set. Plus your Junebug has a 18F1320 tutor built in, you can disconnect it and enable the external ICD connector with the flick of a couple of switches.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  6. #6
    kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent
    Join Date
    Jul 2006
    Location
    Victoria BC, Canada
    Posts
    3,681

    Default

    Quote Originally Posted by RobertD View Post
    it doesn't work, so I don't know why, since it does work on SIM, no problem. I'm using a 16F88.
    Code:
    	decfsz	LBYTE,F
    	goto	loop2
    	decfsz	HBYTE,F
    	goto	loop2
    	end
    
    Are you sure it works in SIM???? The PIC will jump off into LALA land when HBYTE reaches zero and the DECFSZ instruction skips over the "goto loop2" instruction and into unprogrammed flash memory. You need a "goto start" before the "end" directive:

    Code:
    	decfsz	LBYTE,F
    	goto	loop2
    	decfsz	HBYTE,F
    	goto	loop2
    	goto	start
    	end
    
    Last edited by kchriste; 6th September 2008 at 05:02 PM. Reason: goto
    Inside every little problem, is a big problem trying to get out.

  7. #7
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Hi Bill, I was at Creatron today, and the bossman told me about it, so I now have the same as PICKIT2 with Junebug, and can program in circuit. Very simple way to do it too. And I'm seriously considering switching over to the 18F1320, I haven't looked into the code, what I have to change, probably not much, and save myself a lot of headaches.

    Can we meet again for that?

    As far as this goes:

    decfsz LBYTE,F
    goto loop2
    decfsz HBYTE,F
    goto loop2
    end

    There is a goto start instruction after the set up files. And I figure the program will hang when it hits "end". But like you said it might not, however it does work for me, every time... But that's just an intermediary flasher program I wrote quickly to start programming the chip into the other program. Problem is it doesn't flash the little star....

    So I don't know what the problem is. I figured that ought to be simple enough to do, yet when I power the chip it doesn't flash the LEDs.

    Just when I thought I was finished... more bugs____

    So I want to work as FUTZ says, the only way to do it, is in circuit.
    Last edited by RobertD; 6th September 2008 at 10:51 PM.

  8. #8
    futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent
    Join Date
    Sep 2007
    Location
    Vancouver, B.C.
    Posts
    1,980

    Default

    Quote Originally Posted by jpanhalt View Post
    Agree with above, but there is a simple alternative to ICSP, just adapt a ZIF to your breadboard.
    Been dere - done dat. Same crapola. Jacking chips in and out. Slow and tedious.

    Go for ICSP for ease of use.
    =========================
    Futz's Microcontrollers & Robotics
    =========================

  9. #9
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    When plugging the 16F88 directly for ICSP, do you put PGD to RB2, PGC to RB5 and VPP to RB3...?
    Last edited by RobertD; 7th September 2008 at 02:01 AM.

  10. #10
    kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent
    Join Date
    Jul 2006
    Location
    Victoria BC, Canada
    Posts
    3,681

    Default

    Quote Originally Posted by RobertD View Post
    There is a goto start instruction after the set up files. And I figure the program will hang when it hits "end". But like you said it might not, however it does work for me, every time...
    All that the "end" does is tell the compiler to stop generating code. If the PIC was initially blank, then the remaining memory will contain ADDLW,0xFF. This will cause the PC to increment until it wraps around to 0x0000 again which what it will do in SIM giving the appearance of working code. But if the PIC was not blank, I'm not sure what would be in those undefined memory locations once it is programmed with your new code. Add the goto start, where I stated, and try it.
    Last edited by kchriste; 7th September 2008 at 02:04 AM.
    Inside every little problem, is a big problem trying to get out.

  11. #11
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Ok kchriste, I'll try that right now.

    The program flashes once, then nothing. I'm expecting to flash twelve times before stopping. It flashes once or twice the first time I run it, then stops.
    Last edited by RobertD; 7th September 2008 at 02:15 AM.

  12. #12
    kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent
    Join Date
    Jul 2006
    Location
    Victoria BC, Canada
    Posts
    3,681

    Default

    Try putting a 0.1µF capacitor directly across the power pins of the PIC. Also make sure there is a 4.7KΩ-47KΩ pullup resistor on MCLR. If you want it to flash 12 times and then halt then do something like this:
    Code:
    	LIST	p=16F88
    	include "P16F88.inc"
    	__config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON & _LVP_OFF 
    
     errorlevel	-302
    
    
    	Cblock	0x20
    	TIMER1, TIMER2, NumFlashes
    	endc
    	
    	
    
       	banksel	TRISA		;bank 1
    	movlw	0x42		;1MHz clock
    	movwf	OSCCON
    	movlw	0x07		;turn comparators off
    	movwf	CMCON
    
    	movlw	B'11111111'
    	movwf	TRISB		
    	movlw	B'00000010'	
    	movwf	ANSEL
    	movwf	TRISA
    	movlw	B'00000000'
    	movwf	OPTION_REG	
    	banksel	PORTA
    	clrf	NumFlashes
    	clrf	PORTA
     	goto	start
    
    
    delay
    	movlw   D'150'          
       	movwf   TIMER1          
                   
    delay2
    	movlw	D'150'			
    	movwf	TIMER2
    	decfsz  TIMER2,F        
    	goto    $-1             
                   
    	decfsz	TIMER1,F		
    	goto	delay2				
    	return			
    
    start 
     	movlw	D'12'
    	movwf	NumFlashes
    loop2
       	bsf		PORTA,6        
    	bsf		PORTA,7
    	call	delay
    	call	delay
    	clrf	PORTA       
    	call 	delay
    	call	delay
     	decfsz	NumFlashes,F
    	goto	loop2
    hang
    	goto	hang
    	end
    
    Last edited by kchriste; 7th September 2008 at 02:49 AM. Reason: code added
    Inside every little problem, is a big problem trying to get out.

  13. #13
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    Default

    Remember both the 16F88 and the 18F1320 have debug support. Just like the simulator but using hardware. Try single stepping through your program.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  14. #14
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,805

    Default

    Quote Originally Posted by RobertD View Post
    When plugging the 16F88 directly for ICSP, do you put PGD to RB2, PGC to RB5 and VPP to RB3...?
    No,
    PGD->RB7
    PGC->RB6
    Vpp->MCLR

    It's all in the datasheet on the pinout page.

    Mike.

  15. #15
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Thanks Bill, I'm almost done with the 88, but since I'm so close to finish, I'd like to finish this with the 88 first before moving on to the more modern one. If the EEPROM gives me trouble, I might give up on the 88 and move right away. And perhaps I'll do production with the 1320. I did step through and through, and it worked. Maybe I should wire the thing differently. I just ground the PORTB pins directly, and use an internal pull up, is that OK?
    The program works perfectly with the Firefly, it must be the way I wire the thing that's not right.

    And Pommie thanks, Kchriste says to use a pullup resistor on the MCLR pin, I'll have to find out a diagram for that.

    This is the circuit...
    Should I do something with the unused pins...?

    Last edited by RobertD; 7th September 2008 at 11:44 AM.

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. I want star car engine with button like calculator
    By sixssar in forum Electronic Projects Design/Ideas/Reviews
    Replies: 5
    Latest: 10th May 2006, 02:11 PM
  2. Delta-Star or Star-Delta Transformation
    By powersys in forum General Electronics Chat
    Replies: 5
    Latest: 8th February 2006, 04:22 AM
  3. Knight Star Roamer - Looking for manual or schematic
    By Rnktapp in forum Electronic Projects Design/Ideas/Reviews
    Replies: 10
    Latest: 30th September 2005, 06:19 PM
  4. Star Wars - the audtions
    By tansis in forum Chit-Chat
    Replies: 8
    Latest: 9th July 2005, 08:02 PM
  5. MVS chip? (http://www.star.net/people/~mvs/)
    By charliez in forum Micro Controllers
    Replies: 2
    Latest: 11th February 2004, 12:22 AM

Tags for this Thread