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.

New to the uC

Status
Not open for further replies.
1)I like that serial method, maybe i can use that to input my code too? Even only one channel PWM input still works for me.
2)Is it important to change "DEVICE=" to my pic? What does it mean that im apart of the 18F family?
3)My datasheet says pin 2 is "RA0/AN0" does that mean i can I/O ttl data and/or analog? how do i set that up?
4)What is a word? 16bitdata? binary? what if i only wanted 4bit data?
5)is there a swordfish textbook/manual out? or something that has a list of commands for this language?
6)Swordfish is basic right? or is it like QBASIC or WBASIC or something more specific?
 
Start with the easy questions first. Swordfish is a Basic Compiler for the PIC18F-series of microcontrollers. The Special Edition version is free, but limited in program size. The limits are very generous, and I believe you can do everything here in the free version. Swordfish Basic Compiler

For help on Swordfish. look around the Swordfish site. The program is also provided with may sample programs. The most complete reference is available under the [Help] tab within the program.

A word is 16 bits. Bytes are 8 bits.

On some PICs, the pins that can be analog inputs or digital default to analog. Swordfish has a command (SetAllDigital) to make them all digital I/O.

DEVICE tells the compiler while microcontroller you're using. Swordfish supports only the 18F-series parts (i.e., it won't work with a 16F628A). There's a list of supported parts on the Swordfish site.

Your first question I don't understand. You'll need a programmer to get your code into the PIC. The first, last, best and only choice for a programmer is the PICkit 2 from Microchip. It's only $35 and works far better than anything else available. As a second choice, the PICkit 3 is a good option, although it lacks some really handy features of the PICkit 2 and shouldn't be considered an upgrade. Go for the real thing - the clones may work but don't always implement the features you may need.
 
Last edited by a moderator:
thats ok, my first question was just regards to that serial output diagram on the DIY site where that guy was controlling 8 servos using shift registers, I was just thinking that maybe i could do something similar by inputting serial data to READ my PWM

but if the input is analog I may just use a circuit i found called a ramp that decodes pwm to analog voltage!
 
YAY I did it!!! i got a code to flash a Led on and off, i compiled and even got it on to the PIC!


but now how do I activate the uC >>???
 
how does it run it , do i just restart it? do i need to unplug the pickit?

ok, maybe i didnt get that far, im in the pickit programmer and it keeps saying blanking not verified, after eraseing

also how do i get the code from swordfish to pickit loader? or should i use swordfish to upload to pic?
 
You need to program/flash the hex file to the PIC, then it has to verify OK.

then you can either tell it to run form the programmer interface (it will let the MCLR line go to 5V) or unplug and pull the MCLR line high with a 10K or so resistor.
'
 
Last edited:
its not verifying either when i write or when i blank it, it keeps failing at 0000000x00
 
I have no idea how far you really got.

You may have a connection problem between the programmer and the pic. Using the picKit2 software do a "check communications" from the tools menu. It should also tell you which PIC is connected.

If you can not connect you can not do anything with the pic.
 
Last edited:
So My Mclr pin gets tied high with a resistor, then the /mclr button from the pickit goes to the pic end of the resistor?

I test that button but the led doesnt light when i press /CLR on the software maybe i shot my pickit already?

all my pickit other pins light up on tests, do i need the first pickit pin can i bypass??? just to be sure pin one is /MCLR NOT PGM right? i keep getting the feeling that PGM should be connected too for some reason.
 
Jon Chandler has good info on his site.

You do not need to connect the PGM pin.

If you leave the pickit connected you do not need any external components.
Just connect the MCLR VDD VSS PGD and PGC to the the correct pins on the PIC and you should be able to program and run from the IDE.

If you disconnect the pickit you need that 10K resistor between MCLR and VDD on the pic.

In either case I suggest a .1uf cap between the PIC VDD and VSS pins.
 
As an FYI,

I built my own Pickit2 ICSP cable using #24 wire pairs from cat5e cable. It is like 6' long and makes it easy to hook to breadboards etc . I didn't have a 6 pin header on hand so i built it using a bit of PCB and leads clipped from resistors. Basically I soldered the leads in place by sticking em in the breadboard and soldering them onto the (unetched) PCB vertically. Don't worry about shorts at this stage. Then remove the DIY header and used a dremel cutoff wheel to slice just the copper between the pins to isolate 'em. Then solder the wires onto the isolated copper 'fingers'. I did this for both ends to make a m2m cable from the pickit2 to a breadboard.

Never get an error, and I am pushing 6kb Hex proggies.


Ok, 6' long I said....works fine because I didn't use RIBBON cable. Ribbon cable would cause crosstalk. I also removed the wires from the cat 5e sheath so they are not strapped closely together.
 
  • Like
Reactions: 3v0
Wow that sounds like a lot of work.

We have had threads about what one could do to make better longer cables.

picKit2's are rather near the bottom shelf compared to much of what is out there. The good stuff will use shielded ribbon cable but when you are selling the debugger for $35 that is not a real option.
 
Last edited:
Doggy:

Does the Pickit2 s'ware recognise the PIC that U r connected to VIA ICSP when u boot the s'ware?

If so, does the programming fail when u try to write the PIC? Possibly you have the low voltage Programming option still active as all PICs come stock with it now. Please ground the PGM pin via a 10K-100K resistor, and don't use that pin in your code.

Read up on the fuse/config settings for your PIC and then u can disable LVP during the 1st programming exercise and use the PGM as regular GPIO in the future.
 
Wow that sounds like a lot of work.

We have had threads about what one could do to make better longer cables.

picKit2's are rather near the bottom shelf compared to much of what is out there. The good stuff will use shielded ribbon cable but when you are selling the debugger for $35 that is not a real option.

3v0, actually i'm making another custom Pickit 2 header for an smd circuit now. By placing a cheap M22 .08" pitch 6 pin header on the smd PCB I can use a female M22 receptacle as the end of the cable from the Pkit2, thus I can prg. completely assembled smd pcbs.
 
OK, I ended up getting a demo board with a smaller chip on it, 16F886, now my pickit programmer is reading and writing ok! but I accidentally erased the test program on the chip,, I have tried to up load the Led blink tests on port B, but it does not seem to be working? Its hard to tell if im compiling it properly or what i'v noticed slight variations in the code examples, but they should still all work the same right?
 
could these little red light s be the problem?
 

Attachments

  • snap.jpg
    snap.jpg
    132.7 KB · Views: 181
Status
Not open for further replies.

Latest threads

Back
Top