![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Here's the code I'm running Code: list p=18F1320 include <p18F1320.inc> CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF org 0x000 ; RESET vector ; INIT INIT movlw b'01111110' movwf TRISA movlw b'00000001' movwf PORTA movlw b'11000000' movwf TRISB movlw b'11111111' movwf PORTB ; Set pullups ; MAIN MAIN btfsc PORTB,RB2 ; Test button 2 goto MAIN movlw b'10000000' ; Once it's been pressed switch the led and leave it movwf PORTA goto MAIN END Does anyone have any idea what's going on? Looking at the diagram I understand why 1 and 6 are on.. if RA6 is disconnected, 1 is on and 7 is off, I would expect 1, 3 AND 6 to go off, and clearly it's something to do with those three. What am I missing? Thanks | |
| |
| | #2 |
|
Try this: Code: list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
org 0x000 ; RESET vector
INIT
movlw b'01111110'
movwf TRISA
movlw b'00000001'
movwf PORTA
movlw b'00100101' ;Proper port tris setup now (1 = input)
movwf TRISB
movlw 0x80
movwf INTCON2 ; Set pullups
movlw 0x7F
movwf ADCON1 ; Set to all digital
MAIN
btfsc PORTB,RB2 ; Test button 2
goto MAIN
movlw b'10000000' ; Once it's been pressed switch the led and leave it
movwf PORTA
goto MAIN
END
![]() Using the above note from datasheet you can see to enable pullups: Code: movlw 0x80 movwf INTCON2 ; Set pullups Code: bsf INTCON2,RBPU ; Set pullups In datasheet and junebug manual: RB0 = SW1 RB2 = SW2 RB5 = SW3 Now to figure how to set ADCON1 you have to find this: I edited the image so you can see how the registers line up so you can see which PortB pins have what name in ADCON1 register. So you can then: Code: movlw 0x7F movwf ADCON1 ; Set to all digital Code: movlw b'00100101' movwf ADCON1 ; Set RB0, RB2, RB5 digital for button input.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 1st July 2009 at 02:06 AM. | |
| |
| | #3 |
|
Ahh shit.. I even read up on adcon, but I guess I was too used to my arduino. Why is it adcon1, and not just adcon? And thirdly.. New code makes perfect sense, except why aren't we setting bit 7 in adcon1? And finally.. I'm still not exactly sure why the junebug was acting like it was.. it still doesn't really make sense to me and the inconsistency is the weirdest. What does writing to an input pin do? Thanks | |
| |
| | #4 |
|
Most PIC registers are named so to be consistant across the family line.
| |
| |
| | #5 | ||
| Quote:
From the datasheet section 17: 17.0 10-BIT ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE Quote:
ADCON has to do with the Analog to Digital Conversion(ADC). And selecting which pin to read. ADCON1 has to do with setting the PINs to Digital or ANALOG. ADCON2 has to do with the timing of the ADC. Why not set bit 7 of ADCON1: because this is its purpose: "Unimplemented: Read as ‘0’" It has no use. Its not used. Writing to a INPUT pin: i have no clue what would happen... i assume nothing ![]() arduino is more of a shortcut thing i think. You miss out on a lot i suppose. Like the basic stamp. You never get full control. Like of every register. Of course its harder this way but way more satisfying and precise.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 1st July 2009 at 07:01 PM. | |||
| |
| | #6 |
|
Yeah I'm using the arduino for simple robotics and stuff but using pics for smaller more integrated things as well as to make something w/out feeling like I cheated. Arduinos are TOO easy.
| |
| |
| | #7 |
|
Hm now it started randomy switching to LED 5 immediately after starting up now, when it should be LED 6 until I hit the button 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 b'01111110' movwf TRISA movlw b'00000001' movwf PORTA movlw b'00100101' movwf TRISB bsf INTCON2,RBPU ; Set pullups movlw 0x7F movwf ADCON1 ; Set to all digital ; MAIN MAIN btfss PORTB,RB2 goto MAIN movlw b'10000000' movwf PORTA goto MAIN END | |
| |
| | #8 |
|
Have to bump this. Haven't touched my junebug in a while, so it's running the code in the above post. It won't connect anymore, resetting gets the right LED lit but plugging it in make it quickly switch to what should be lit only after pressing the button. Program also completely ignores button presses. Maybe I screwed up soldering in. Video is posted and pictures of my soldering job. Any ideas what I could have done wrong? Video 1 2 3 Video 2 Last edited by Gfaja; 19th July 2009 at 10:16 PM. | |
| |
| | #9 |
|
For self running turn off DIP1-1.
| |
| |
| | #10 |
|
The video shows that his Junebug will not connect to MPLAB. Try reloading the firmware using the bootstrap loader button (small button near the 18F2550). I have to run... will finish this latter. 3v0
__________________ Please post questions to the forums. PM's are for personal communication. BCHS/3v0's Tutorials Junebug USB PIC programmer kit., USB Bit Whacker, The 15 Minute Printed Circuit Board! (+drill time) | |
| |
| | #11 |
|
No luck with either. Got "Usb device not recognized" bubble in xp
| |
| |
| | #12 |
|
Hold down the pushbutton while plugging in the USB. Does the red busy LED flash?
| |
| |
| | #13 |
|
Nope. Yellow is dimly lit. Now I consistently get the USB not recognized message when plugging it in.
| |
| |
| | #14 |
|
Hmm remove the 18F2550. Is there a color dot painted on the bottom? A programmed Junebug only needs power & a working crystal (plus the pushbutton) to get the LED flashing. | |
| |
| | #15 |
|
sigh.... the chip was barely in the socket.. one of the indents is white? put it back in and it flashed red and is updating its software right now. yellow is off. Now have it running, but still have it so LED 5 is light a split second after LED 6 as if I had hit the button. That or it switches randomly/not when I press the switch. So basically the videos are still accurate other than the programming problem. Any ideas? | |
| |
|
| 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 |