![]() |
![]() |
![]() |
|
|
|||||||
| 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 have a problem where I can run programs with the Mplab/Junebug combo but the Junebug tutor will not standalone. I know it's not the Junebug and is most likely not setting the correct config registers. If I set them in Mplab will that carry out to the pic when I program it? Is there a good tutorial on the config bits/bytes somewhere. I have done a bit of reading but have not gotten back to trying some of the things out. I did print out the 18F1320.inc file which has some info ( a bit confusing ) but did not find how to set the different clock speeds when using the internal rc osc. Thanks.
|
|
|
|
|
|
|
(permalink) |
|
Turn DIP SW 1,2,3 off and the tutor is completely separated from the programmer.
As for the config settings my favorite defaults for MPASM are. Code:
list p=18F1320
include <p18F1320.inc>
CONFIG OSC=INTIO2,WDT=OFF,LVP=OFF
Code:
movlw 0x62 ; 4MHz OSC
movwf OSCCON
Perhaps I'll add this stuff to the Junebug manual. PS remind me to run it through Pommies PIC code formatter next time Last edited by blueroomelectronics; 6th June 2008 at 04:53 PM. |
|
|
|
|
|
|
(permalink) |
|
Ok, I added that to my little play program.
I compiled via Mplab in release mode, hit start and it runs. If I switch off 1,2,3 then it still runs. Power off, with switch 1,2,3 off, connect the power, this should run the program, correct?? I just can't get this to work, what am I doing wrong?? I will post the code here once I figure out how. Thanks, Mike |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Hi Mike, To get your program to run stand alone you have to select the junebug as programmer - not debugger. When selected as a debugger it downloads the debug exec even if you select the release setting. It appears to be a bug in MPLAB. Mike. |
||
|
|
|
|
|
(permalink) |
|
Code:
; Blue2 Project
;******************************************************************************
LIST P=18F1320, F=INHX32 ;directive to define processor and file format
#include <P18F1320.INC> ;processor specific variable definitions
;******************************************************************************
;Configuration bits
;; Oscillator Selection:
CONFIG OSC=INTIO2,LVP=OFF,WDT=OFF
;******************************************************************************
;Variable definitions
;;
cblock 0x01
d1
d2
d3
endc
;;
;******************************************************************************
;Reset vector
RESET_VECTOR CODE 0x0000
goto Main ;go to start of main code
;******************************************************************************
;High priority interrupt vector
HI_INT_VECTOR CODE 0x0008
bra HighInt ;go to high priority interrupt routine
;******************************************************************************
;Low priority interrupt vector
LOW_INT_VECTOR CODE 0x0018
bra LowInt ;go to low priority interrupt routine
;******************************************************************************
;High priority interrupt routine
CODE
HighInt:
; *** high priority interrupt code goes here ***
retfie FAST
;******************************************************************************
;Low priority interrupt routine
LowInt:
retfie
;******************************************************************************
;Start of main program
Main:
;
clrf LATB; clear output latch
movlw 0x7f
movwf ADCON1; set port b for digital inputs
bcf INTCON2, RBPU ; turn on soft pullups
;
movlw 0x02 ;make sure osc is set
movwf OSCCON
;
BURP:
btfss PORTB, RB0; check for button #1 pressed
call BUTT1
btfss PORTB, RB2; check for button #2 pressed
call BUTT2
btfss PORTB, RB5; check for button #3 pressed
call BUTT3
;
goto BURP
;
L1:
LED1 bcf TRISA,0 ; RA0 output
bcf TRISA,6 ; RA6 output
bsf TRISA,7 ; RA7 tristate (open)
bsf LATA,0 ; RA6 High (5V)
bcf LATA,6 ; RA7 Low (GND)
call DubDelay
return
L2:
LED2 bcf TRISA,0 ; RA0 output
bcf TRISA,6 ; RA6 output
bsf TRISA,7 ; RA7 tristate (open)
bcf LATA,0 ; RA6 Low (GND)
bsf LATA,6 ; RA7 High (5V)
call DubDelay
return
L3:
LED3 bsf TRISA,0 ; RA0 tristate (open)
bcf TRISA,6 ; RA6 output
bcf TRISA,7 ; RA7 output
bsf LATA,6 ; RA6 High (5V)
bcf LATA,7 ; RA7 Low (GND)
call DubDelay
return
L4:
LED4 bsf TRISA,0 ; RA0 tristate (open)
bcf TRISA,6 ; RA6 output
bcf TRISA,7 ; RA7 output
bcf LATA,6 ; RA6 Low (GND)
bsf LATA,7 ; RA7 High (5V)
call DubDelay
return
L5:
LED5 bcf TRISA,0 ; RA0 output
bsf TRISA,6 ; RA6 tristate (open)
bcf TRISA,7 ; RA7 output
bcf LATA,0 ; RA0 Low (GND)
bsf LATA,7 ; RA7 High (5V)
call DubDelay
return
L6:
LED6 bcf TRISA,0 ; RA0 output
bsf TRISA,6 ; RA6 tristate (open)
bcf TRISA,7 ; RA7 output
bsf LATA,0 ; RA7 High (5V)
bcf LATA,7 ; RA6 Low (GND)
call DubDelay
;
return
;bra LED1 ; repeat
bra Main
;; END
;******************************************************************************
DubDelay
movlw 0x50
movwf d1
movlw 0x50
movwf d2
Del_1
decfsz d1, f
goto $+4
decfsz d2, f
goto Del_1
goto $+2
nop
return
;******************************************************************************
;
BUTT1
movlw 0x03
movwf d3
B11
call L1
call L2
call L3
call L4
call L5
call L6
decfsz d3, f
goto B11
bsf TRISA,0
bsf TRISA,6
bsf TRISA,7
return
BUTT2
movlw 0x03
movwf d3
B22
call L1
call L2
call L3
call L4
call L5
call L6
call L5
call L4
call L3
call L2
decfsz d3, f
goto B22
bsf TRISA,0
bsf TRISA,6
bsf TRISA,7
return
BUTT3
movlw 0x03
movwf d3
B33
call L3
call L4
decfsz d3, f
goto B33
bsf TRISA,0
bsf TRISA,6
bsf TRISA,7
;
movlw 0x03
movwf d3
B34
call L2
call L5
decfsz d3, f
goto B34
bsf TRISA,0
bsf TRISA,6
bsf TRISA,7
;
movlw 0x03
movwf d3
B35
call L1
call L6
decfsz d3, f
goto B35
bsf TRISA,0
bsf TRISA,6
bsf TRISA,7
return
END
|
|
|
|
|
|
|
(permalink) |
|
Umm... Why is all your code double-spaced? Makes it WAY too long. You must spend all your time scrolling up and down.
__________________
========================= Futz's Microcontrollers & Robotics ========================= |
|
|
|
|
|
|
(permalink) |
|
Why not something more like this:
Code:
; Blue2 Project LIST P=18F1320 #include <P18F1320.INC> CONFIG OSC=INTIO2,LVP=OFF,WDT=OFF cblock 0x01 d1,d2,d3 endc org 0x0000 Main clrf LATB ;clear output latch movlw 0x7f movwf ADCON1 ;set port b for digital inputs bcf INTCON2,RBPU ;turn on soft pullups movlw 0x02 ;make sure osc is set movwf OSCCON BURP btfss PORTB,RB0 ;check for button #1 pressed call BUTT1 btfss PORTB,RB2 ;check for button #2 pressed call BUTT2 btfss PORTB,RB5 ;check for button #3 pressed call BUTT3 goto BURP L1 LED1 bcf TRISA,0 ;RA0 output bcf TRISA,6 ;RA6 output bsf TRISA,7 ;RA7 tristate (open) bsf LATA,0 ;RA6 High (5V) bcf LATA,6 ;RA7 Low (GND) call DubDelay return L2 LED2 bcf TRISA,0 ;RA0 output bcf TRISA,6 ;RA6 output bsf TRISA,7 ;RA7 tristate (open) bcf LATA,0 ;RA6 Low (GND) bsf LATA,6 ;RA7 High (5V) call DubDelay return L3 LED3 bsf TRISA,0 ;RA0 tristate (open) bcf TRISA,6 ;RA6 output bcf TRISA,7 ;RA7 output bsf LATA,6 ;RA6 High (5V) bcf LATA,7 ;RA7 Low (GND) call DubDelay return L4 LED4 bsf TRISA,0 ;RA0 tristate (open) bcf TRISA,6 ;RA6 output bcf TRISA,7 ;RA7 output bcf LATA,6 ;RA6 Low (GND) bsf LATA,7 ;RA7 High (5V) call DubDelay return L5 LED5 bcf TRISA,0 ;RA0 output bsf TRISA,6 ;RA6 tristate (open) bcf TRISA,7 ;RA7 output bcf LATA,0 ;RA0 Low (GND) bsf LATA,7 ;RA7 High (5V) call DubDelay return L6 LED6 bcf TRISA,0 ;RA0 output bsf TRISA,6 ;RA6 tristate (open) bcf TRISA,7 ;RA7 output bsf LATA,0 ;RA7 High (5V) bcf LATA,7 ;RA6 Low (GND) call DubDelay return ;bra LED1 ;repeat bra Main ;*********************************** DubDelay movlw 0x50 movwf d1 movlw 0x50 movwf d2 Del_1 decfsz d1, f goto $+4 decfsz d2, f goto Del_1 goto $+2 nop return BUTT1 movlw 0x03 movwf d3 B11 call L1 call L2 call L3 call L4 call L5 call L6 decfsz d3, f goto B11 bsf TRISA,0 bsf TRISA,6 bsf TRISA,7 return BUTT2 movlw 0x03 movwf d3 B22 call L1 call L2 call L3 call L4 call L5 call L6 call L5 call L4 call L3 call L2 decfsz d3, f goto B22 bsf TRISA,0 bsf TRISA,6 bsf TRISA,7 return BUTT3 movlw 0x03 movwf d3 B33 call L3 call L4 decfsz d3, f goto B33 bsf TRISA,0 bsf TRISA,6 bsf TRISA,7 movlw 0x03 movwf d3 B34 call L2 call L5 decfsz d3, f goto B34 bsf TRISA,0 bsf TRISA,6 bsf TRISA,7 movlw 0x03 movwf d3 B35 call L1 call L6 decfsz d3, f goto B35 bsf TRISA,0 bsf TRISA,6 bsf TRISA,7 return end The double labels are weird and unnecessary too, but perfectly legal. Colons are not necessary on labels in this assembler.
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 7th June 2008 at 08:16 AM. |
|
|
|
|
|
|
(permalink) |
|
|
|
|
|
|
|
|
(permalink) |
|
Actually it's not double spaced, not sure why it came out that way. It may not be efficient code, but I'm still getting back to it and learning by adding more stuff and doing things in different ways.
I did not see the post just after mine as I decided to crash, need a little sleep as I have work today also. I'll go back and check me Mplab settings. Thanks |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Thanks, Mike |
||
|
|
|
|
|
(permalink) |
|
I've added the header stuff to the manual, perhaps a debug / release note might be useful too.
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
;; Use the following to set Oscillator speed in your program ; ; movlw 0x?? ; where ? is from the following table ; movwf osccon; ;0x72=8mhz ;0x62=4mhz ;0x52=2mhz ;0x42=1mhz ;0x32=500khz ;0x22=250khz ;0x12=125khz ;0x02=31khz ; ;************************************************* ***************************** |
||
|
|
|
|
|
(permalink) |
|
That table will work fine, I'm putting migrating tips in the JPUG. That would make a good one.
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| using registers | unibaza | Micro Controllers | 1 | 8th August 2007 02:00 PM |
| CPU / RAM memory registers? | AceOfHearts | Micro Controllers | 8 | 17th July 2007 07:50 PM |
| Help loading shift registers... | jrz126 | Micro Controllers | 0 | 14th November 2005 12:12 PM |
| MPLAB IDE and MPLAB Sim irritating behaviour | Joel Rainville | Micro Controllers | 3 | 14th August 2005 08:37 PM |
| shift registers | jrz126 | Electronic Projects Design/Ideas/Reviews | 8 | 25th September 2004 01:35 AM |