Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 21st July 2009, 03:25 AM   #16
Default

Yep the dot means I programmed it. You have to push down pretty firmly on that machine socket.

Since the Junebug sounds like it's ok, IMO it would be an excellent time to give the debug mode a spin.

Add the two following lines to the beginning of your code (else the debug mode is really slow)

movlw 0x72
movwf OSCCON

This will speed up the PIC to 8MHz

Then simply pick the debug mode instead of the program mode. You can single step , run , animate, set breakpoints and watch variables.

TIP open a "watch" window and watch PORTB & TRISB
You can toggle bits directly in this mode and see the results directly on the LEDs.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Old 21st July 2009, 06:22 AM   #17
Default

Ah ok. I will do that. I had a problem with only being allowed one breakpoint, and it was super slow, I assumed it ran by default on full speed.
Gfaja is offline  
Old 21st July 2009, 12:34 PM   #18
Default

The default internal osc speed is 31.25 kHz, good for flashing LEDs but really slow for the debugger.

I started out with a Parallax Clearview 5x ICE for the 16C54 way back before debuggers were available.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Old 22nd July 2009, 01:19 AM   #19
Default

Hm, I get popups for stupid things,
Quote:
Stepping Target
PICkit 2 Ready

Stepping Target
PICkit 2 Ready

Stepping Target
PK2Error0029: Failed PICkit 2 operation: Step
Quote:
Running Target
PK2Error0029: Failed PICkit 2 operation: Halt
PICkit 2 Ready

Target Halted
It fails the step when it's on the movwf TRISB and the bsf is the next command (consistently)
Gfaja is offline  
Old 24th July 2009, 08:54 PM   #20
Default

Hmm make sure DEBUG is enabled (from the MPLAB pulldown) and change TRISB bits 6&7 to 1.
Code:
movlw b'11100101'    ;Proper port tris setup now (1 = input)
movwf TRISB
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/

Last edited by blueroomelectronics; 24th July 2009 at 08:55 PM.
blueroomelectronics is offline  
Old 25th July 2009, 09:31 PM   #21
Default

Same problem on the same line. Why are we setting those two bits as input? And not sure what you mean about debug enabled.. the debugger is connected if that's what you mean.
Gfaja is offline  
Old 26th July 2009, 12:41 AM   #22
Default

Hmm, try adding DEBUG = ON to the CONFIG line.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Old 26th July 2009, 01:38 AM   #23
Default

:s nothing's changed. This is bizarre
Gfaja is offline  
Old 27th July 2009, 01:16 AM   #24
Default

RBPU needs to be cleared to enable the pullups.
Here's a working version of the code and it worked with the debugger, just make sure the DEBUG pulldown is selected.
Code:
; *** Junebug 18F1320 LED sequencer demo ***
; Flashes LEDs1 thru 6 from left to right forever
; DIP Switch (SW6) must have TUTOR on (SW6-1,2,3) all other switches off
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF

org 0x000            ; RESET vector
; INIT
INIT    movlw    0x72            ; 8MHz OSC
        movwf    OSCCON
        movlw     0x7F
        movwf     ADCON1      ; Set to all digital 
        movlw     b'00111111'
        movwf     TRISA        
        movlw     b'01111111'
        movwf     PORTA        
        movlw     b'00100101'
        movwf     TRISB
        bcf       INTCON2,RBPU     ; Enable pullups

MAIN    btfss     PORTB,RB2        ; is button #2 pressed?
        goto     LED3            ; yes?
LED4    movlw     b'10000000'        
        movwf     PORTA            ; LED4 on, 3 off
        goto     MAIN
LED3    movlw     b'01000000'        ; RB2 pressed
        movwf     PORTA            ; LED3 on, 4 off
        goto     MAIN            


END
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/

Last edited by blueroomelectronics; 27th July 2009 at 01:20 AM.
blueroomelectronics is offline  
Old 27th July 2009, 02:15 AM   #25
Default

Hm, all seems to be working. Still not sure exactly what was going wrong but it's working now. Thanks so much for the help
Gfaja is offline  
Old 27th July 2009, 02:29 AM   #26
Default

Actually I must have fucked up something soldering.

Code:
; *** Junebug 18F1320 LED sequencer demo ***
; Flashes LEDs1 thru 6 from left to right forever
; DIP Switch (SW6) must have TUTOR on (SW6-1,2,3) all other switches off
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF, DEBUG = ON

org 0x000			; RESET vector
; INIT
INIT	
		movlw 0x72
		movwf OSCCON			; Speed the clock

		movlw 0x7F
		movwf ADCON1      ; Set to all digital 

		movlw b'01111110'
		movwf TRISA
		
		movlw b'00000001'
		movwf PORTA		

		movlw b'00100101'
		movwf TRISB

		bsf   INTCON2,RBPU     ; Set pullups

MAIN	
		btfss PORTB,RB2			; Is button 2 pressed?
		goto LED6				; Yes?
		movlw b'10000000'
		movwf PORTA
		goto MAIN
LED6	movlw b'00000001'
		movwf PORTA
		goto MAIN

END
Middle button is unresponsive but when I have it run, it may flicker, so I'm not sure if there's something wrong with its connection. As I was typing this with the thing on my lap it started flickering, and now both are lit.

Any thing that you can think is likely to have been soldering improperly? I'm not wearing a wrist strap or anything but I can't really see it having that kind of affect.

Gfaja is offline  
Old 27th July 2009, 04:29 AM   #27
Default

You must change the bsf to bcf
bcf INTCON2,RBPU

to enable pullups or the buttons will not work properly.

From MPLAB's debug, open a Watch window and watch PORTB, animate the program and press button #2 and you should see PORTB value changing.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Old 27th July 2009, 06:26 AM   #28
Default

OH post #2 says I could use bsf. works great. Thank you so much.
Gfaja is offline  
Reply

Tags
junebug, led, pic

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Junebug Problem 3v0 Micro Controllers 29 14th January 2009 09:16 AM
Problem with junebug and mplab 8.10 jerryf Micro Controllers 12 1st December 2008 01:48 PM
Problem with junebug jerryf Micro Controllers 6 30th November 2008 04:44 PM
Junebug INT2 problem futz Micro Controllers 9 15th November 2007 03:32 AM
Junebug tutor LEDs futz Micro Controllers 5 11th November 2007 05:24 AM



All times are GMT. The time now is 11:40 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker