Continue to Site

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.

JUNEBUG has arrived

Status
Not open for further replies.
F10 is compile and program But like i said I could never get it to work with swordfish it doesn't see the PK2CMD as exe on my computer
 
It says programming successful
waiting for file update (click button again to exit)

Nothing on the Uart tool page

connected at 9600 baud
 
Bill It will work lol I just needed this part /PPIC$target-device$ /F$long-hex-filename$ /M /R /H2
 
I caught the typo and the 0&O look very similar.
If you're having trouble with O and 0 looking too much alike, you should switch to a proper programmer's font. You're probably using Courier New, which does not have a crossed zero. It looks like this:
couriernew.jpg

What you want is a monospaced font like Consolas or other mono font made for programming, with crossed zeros. You'll never mistake a crossed zero for the letter O. Consolas looks like this:
consolas.jpg
 
Last edited:
do I have to have a pic

inserted into the socket to run the program?
Because I then have to order one as I don't have access to any here in town.
just curious, can I copy the code from a pic thats in a circuit?
I have 2 timers that are used for the pinewood derby that have a pic, and oscillator and a resistor array plus an led readout.
oh yea an IR detector as well.
 
Try the tutor for your first program, switch 1,2,3 on will connect it.
A simple flashing LED program is a good start.
Something like this

While (1)
Toggle(RA.0)
DelayMS(500)
Wend
 
Try the tutor for your first program, switch 1,2,3 on will connect it.
A simple flashing LED program is a good start.
Something like this

While (1)
Toggle(RA.0)
DelayMS(500)
Wend

That doesn't work as the other two charlieplex pins are still input.

Try,
Code:
Device = 18f1320
Clock = 4
Config OSC = INTIO2, WDT = OFF, LVP = OFF
OSCCON = $62
TRISA=%10111110         //A0 & 6 output
PORTA=0
While (true)
    Toggle(PORTA.0)
    DelayMS(500)
Wend
End

Mike.
 
Success, that one works.
I got the recommended read that ole blue suggested "Microprocessors from assembly language to C using the PIC 18Fxx2"

What a snooze fest!

Anyone have some suggested reading that will guide me through this?
For example:
what does this mean:

Device = 18f1320
Clock = 4
Config OSC = INTIO2, WDT = OFF, LVP = OFF
OSCCON = $62
TRISA=%10111110 //A0 & 6 output
PORTA=0
While (true)
Toggle(PORTA.0)
DelayMS(500)
Wend
End

If I knew the syntax and what it meant I could find my way.

This guy says 'do it like this' while the other person says 'no this is the way', Kind of leaves me sayin "Huh"? Especially when I don't know what you are talking about in the first place.

Go ahead and sigh all you want, this is a foreign language to me.

There has go to be a book/manual that walks the 'newly initiated' to the realm of PIC's in the ways of hex.
 
Last edited:
copied/pasted build succesful but errors

I copied / pasted the code then F10
it said build sucessful but I get several syntax errors and reset microcontroller.
now lets see if I understand this.
I load this into junebug then test it and the leds should blink??
Oh by the way I saw that link dealing with the 555 timer type sounder.
Now you got me thinking about the Deer Chaser gizmo
 

Attachments

  • Capture3-31-2009-7.59.55 AM.jpg
    Capture3-31-2009-7.59.55 AM.jpg
    90.2 KB · Views: 123
  • Capture3-31-2009-7.59.38 AM.jpg
    Capture3-31-2009-7.59.38 AM.jpg
    188.6 KB · Views: 134
As I said in an earlier post, use F9 - not F10. This will produce a hex file. You then use the PicKit2 programming software to load the hex file into your chip. As for the errors, you are not compiling what I posted earlier, you are compiling the include file.

Mike.
 
If I knew the syntax and what it meant I could find my way.

Go ahead and sigh all you want, this is a foreign language to me.

I'll try and explain the various lines,

Device = 18f1320

Pretty simple - tell the compiler which chip your using.

Clock = 4

Again, tell the compiler how fast it will run - 4MHz in this case.

Config OSC = INTIO2, WDT = OFF, LVP = OFF

Tricky one, this is the dreaded configuration word. It tells the chip what to expect and what we want it to do. In this case we want the OSCillator to be INTernal and the 2 pins normally used for a crystal to be normal IO pins. We don't want the Watch Dog Timer or Low Voltage Programming to be enabled.

OSCCON = $62

If you check the data sheet then OSCCON CONtrols the OSCillator. In this case we want it to run at 4MHz.

TRISA=%10111110

Ahhh, the TRIS register, names because when we set a bit in it the corresponding port bit becomes an input. Set it to zero and the pins become output. When set as output we can write a 1 or 0 to the port bit and the corresponding pin will become 5V or 0V. The name tris is because the pin can have three states (input - 5V -0V) Hence TRIState.

PORTA=0

This just set's all pins that are outputs (A0 and A6) to 0V.

While (true)

This is an instruction that causes the program to go in a loop until the expression in the brackets is false. In this case the expression is always true and so it will loop forever.

Toggle(PORTA.0)

Toggle means invert. If it was 1 make it 0 and vice versa. The .0 on PORTA signifies that we want to flip the state of bit 0 of port A.

DelayMS(500)

Pretty obvious, wait 500mS.

Wend

This is how we tell the compiler where we want the while loop (see above) to end. It is a short form of While END.

End

Tells the compiler that we're done. No more code.

Well, the above makes sense to me but then I understand it. I'm sure it's gobbledygook to others but if you spend a little time it will start to make sense.

Mike.
 
Thanks for explaining it Mike, Is there a book that has this kind of information? What would you recommend for a first timer?
 
The Swordfish manual and the built in help provide plenty of examples. You might try peeking at the many BASIC Stamp examples on the Parallax site. They will need to be converted to Swordfish Syntax but should give you an idea on how BASIC is structured. It's a very English like language and was very common on 1980's home computers.
 
I'm pretty fluent in basic, learned it on the TRS-80 and with the stamps, but there is good documentation, (Books) that can guide you through it.

I guess I'm old school when it comes to documentation, I like printed materials.
 
Pommie's explanation was extremely helpful, at least for someone who doesn't have much experience in this. I am sure it is grade school level to most, but I appreciate the detail given.
 
now what?

I recopied / pasted then F9
all is ok
lots easier than mplab but now what??
need to look at junebug manual to see if it is referenced as to what to do now.
coarse I need to assemble the junebug first I guess??
 
If you have setup the PK2CMD.exe to work with Swordfish it's F<10> (compile & program). F<9> will only compile to a .hex file. You could use PICkit2 standalone software and load the hex file that way.

Yes you've gotta finish building your Junebug first :)
 
I downloaded the pickit2 file

now what?
I looked at mikeroes post about the beep example but it uses the 16f84
can the code be adapted to the 18f1320?
I guess the Junebug will only program 18f1320?
after seeing the example mike posted I got to thinking that I could adapt to use in my deer chaser gizmo??
starting assembly tomorrow of Junebug.
Did get the 5 PIRs today.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top