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.

More inchworm help needed

Status
Not open for further replies.

Andy1845c

Active Member
I got my inchworm to connect. I found I had enough room to simply plug the inchworm board directly into the serial port on my computer. Not sure if this is okay, but it connected.

A couple questions...

1. What exactly do I want the Device in MPLAB set to? Should it be set for the 16F54 I want to program, or for the 16F887 on the inchworm board?

2. Is ICD07010400.hex the correct file to be downloading as the OS? It is the only one that shows up for me.

3. I am trying to run a 16F54 with a 8MHz crystal. Trying to follow Bill's Hello World. I set the config bits to HS and this is what I have for the program:

list p=16F54 ?
include <p16f54.inc> ?
_CONFIG 0x0FFE
org 0
bsf STATUS, RP0
movlw b'00001110'
movwf OPTION_REG
movlw b'11111110'
movwf TRISB
bcf STATUS, RP0
movlw 1
xorwf PORTB, f
sleep
end

I'm quite sure somthing must be wrong here, because it won't build. Is the top part I have in red correct for a 16F54?

Many thanks once again.

Andy
 
The 16F54 is one really old device. Works a little differently than most other PICs. I don't have 16F54 handy but this might work. You choose the 16F54 from the config menu.

Code:
        list p=16F54
        include <p16f5x.inc>
        __CONFIG 0x0FFE
        org 0
        bsf STATUS, PA0
        movlw b'00001110'
        OPTION
        movlw b'11111110'
        TRISB
        bcf STATUS, PA0
        movlw 1
        xorwf PORTB, f
        sleep
        end
 
Last edited:
Thanks Bill, That got me a step farther. It built just fine, but now when I go to program, it "cannot validate a target device".
I'm gonna go over my connections and I'll check back.
 
1. What exactly do I want the Device in MPLAB set to? Should it be set for the 16F54 I want to program, or for the 16F887 on the inchworm board?
Set it for 16F54
2. Is ICD07010400.hex the correct file to be downloading as the OS? It is the only one that shows up for me.
Since you've already connected to your ICD, you don't have to worry about the OS on the inchworm/ICD2 anymore. MPLAB will download the correct OS when it detects you're trying to program a PIC that requires a different OS running on the Inchworm/ICD2.
 
Just an update, I did get the 16F54 to program. I had the power setting on MPLAB wrong. Never even though about that. I though "target has its own power supply" ment the inchworm has its own supply. I just didn't read the 2 choices all that well, embarassing as that is:eek:

I did not, however get the LED to blink. Is there a reason I can't just connect it between RB0 and GND thought a 470:eek:hm: resistor? Why does the Blueroom hello world have it also tied into VPP with the diode and 22k:eek:hm: resistor? I haven't figured that out yet.

I did get a hold of a few 12F683's. Would these little guys be okay to learn with? I looked at the datasheet and it appears it has the internal oscillator. It looks like the pins are all labled with many differnt things, and that kinda confuses me. I am going to get some 16F84s, but i want to get at least an led or 2 flashing with what I have.

Is there any place on the web that has free programs for PICs that can be used, or modified for use?
 
Andy1845c said:
I did get a hold of a few 12F683's. Would these little guys be okay to learn with? I looked at the datasheet and it appears it has the internal oscillator. It looks like the pins are all labled with many differnt things, and that kinda confuses me. I am going to get some 16F84s, but i want to get at least an led or 2 flashing with what I have.

The PIC12F683 is a very good choice and it is the only 8-pin PIC micro controller with the CCP module and TMR2 up to now. The I/O port of this PIC is called GPIO and not PORTA or PORTB. If you're looking for some programs, you may google for PIC12F629 or 675 projects. The configuration of the PIC12F683 is similar. You'll have to change something, though (internal oscillator selection, peripheral features configuration, no OSCCAL, ...)
 
Andy1845c said:
I did not, however get the LED to blink. Is there a reason I can't just connect it between RB0 and GND thought a 470:eek:hm: resistor? Why does the Blueroom hello world have it also tied into VPP with the diode and 22k:eek:hm: resistor? I haven't figured that out yet.

I always feel better when the LED blinks :D
If this is too elementary please do not be insulted.

Think of it this way. One side of the LED is tied to +5 (VDD) via the 470R resistor. The other side is hooked to the PIC IO pin.
To turn on the LED the PIC drives the pin low creating a ground path for the LED. The PIC is sinking the LED (serving as ground).

PIC-IO-PIN ----- LED ------ 470R ------ +5

The schematic shows VPP tied to the same VDD point via the LED and 22K resistor, they do not effect the LEDs operation.

Can you single step the program ? If not you may still have problems with the config settings or OSC.

If you can single step check to see if you wired it right.
Maybe you got the pins on the LED in backwards. Try switching it.
The check to see if you entered the code correctly. You used cut and past, yes?

3v0

If you hooked the LED up as you suggested it would work as long as you got the polarity correct. In this case it would come on when the IO pin was high. This is called sourcing.
Think of it this way, you source the current to a part or sink it to ground.
 
Last edited:
3v0 said:
I always feel better when the LED blinks :D
If this is too elementary please do not be insulted.
Yeah, the LED blinking would have made my day:D

The schematic shows VPP tied to the same VDD point via the LED and 22K resistor, they do not effect the LEDs operation.
After doing a little reading, is diode and 22k:eek:hm: resistor for the power on reset?

Can you single step the program ? If not you may still have problems with the config settings or OSC.

lol, you may have not been elementry enough for me. I don't know how to single step the program. I guess I can look it up. It may very well be my oscillator though. Its a a beauty:rolleyes: If I had a scope, could I check to see if it was oscillating?

Maybe you got the pins on the LED in backwards. Try switching it.

Tried this already

The check to see if you entered the code correctly. You used cut and past, yes?

Yep, I cut and pasted Bill's code from previously in this thread.

I think i'll try the little 12F if I can find some code to cut and paste for it. I don't understand it enought to try and write it from scratch yet.

I'll post back later.

Thanks for the help!

Andy
 
You can probe the osc out pin with a 10x probe. In another thread someone talked about using a few megaohm of resistance between the probe and the pin to allow the use of a 1x probe. There are two osc pins if you probe the wrong one it will stop the osc from osc. I keep mixing up which one to probe so I check both. On the larger chips you probe the higher numbered osc pin which IIRC is the osc out pin. Could be wrong.

After doing a little reading, is diode and 22k resistor for the power on reset?
Yes

It is the ICD that makes the inchworm the great tool that it is. There is a drawback to you selection of chip. The 16F54 does not support ICD (In Circuit Debug). ICD is very handy when you are learning in that it allows you to step/walk through the program on the processor and examine memory and registers along the way.

The 12F683 does allow for ICD. The code for the 12F509 should work but you may need to change the config value.

If you want to make like easy get one of the chips Bill uses in the poster like the 16F84A.

When a PIC does not run it is most often the CONFIG value is wrong. Past that check the wiring.
 
3v0 said:
You can probe the osc out pin with a 10x probe. In another thread someone talked about using a few megaohm of resistance between the probe and the pin to allow the use of a 1x probe.

A x10 probe is simply a 9 Meg resistor in series with the probe, with a small value trimmer across it, which you adjust to be 1/9th of the scope input capacitance (including the cable capacitance) - so the probe compensates for the cable as well. As we're only looking to see if it's oscillating, a simple 9 Meg resistor will be good enough.
 
How does one select a CONFIG value? I tried the 12F509 code as is and it didn't work. I also got a bunch of warnings on the build step

Warning[205] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 2 : Found directive in column 1. (list)
Warning[205] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 3 : Found directive in column 1. (include)
Warning[205] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 4 : Found directive in column 1. (__CONFIG)
Warning[205] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 5 : Found directive in column 1. (org)
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 6 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 7 : Found opcode in column 1. (option)
Warning[224] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 7 : Use of this instruction is not recommended.
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 8 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 9 : Found opcode in column 1. (tris)
Warning[224] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 9 : Use of this instruction is not recommended.
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 10 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 11 : Found opcode in column 1. (xorwf)
Warning[203] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 12 : Found opcode in column 1. (sleep)
Warning[205] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\D.ASM 13 : Found directive in column 1. (end)

Whats a directive and an opcode?

What should the osc be set to in the config bits for the 12F683?

Do I need the power up reset to do the blinking LED?

I'm going to go do some more reading. I feel like i'm trying to stand before I can crawl here, but its no fun to just read about code/PICs and not be able to try what I read and make sense of it.
 
**From BlueRoomElectronics.com**





;*** WDT reset toggles GP2
list p=12F509
include <p12F509.inc>
__CONFIG 0x0FFE
org 0
movlw b'00001110'
option
movlw b'11111011'
tris GPIO
movlw b'00000100'
xorwf GPIO, f
sleep
end
 
Andy1845c said:
**From BlueRoomElectronics.com**





;*** WDT reset toggles GP2
list p=12F509
include <p12F509.inc>
__CONFIG 0x0FFE
org 0
movlw b'00001110'
option
movlw b'11111011'
tris GPIO
movlw b'00000100'
xorwf GPIO, f
sleep
end

You need to use the 'Code' tags to surround your code, so the browser doesn't remove any formatting - which is actually what is wrong with your code anyway.

The error messages are pretty explicit - you are entering code in coloumn 1, only labels are allowed there!.
 
Okay, now i'm as confused as ever.

Do I need the "code tag" for posting my code on the forums or for entering it in MPLAB?

What is column 1? I searched the help in MPLAB and the web and nothing explained what it is and how to avoid doing whatever I am doing thats wrong.
 
Thanks.... but sadly, it only got me down to 2 warnings

Warning[224] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\A.ASM 7 : Use of this instruction is not recommended.
Warning[224] C:\DOCUMENTS AND SETTINGS\ANDY JOHNSON\DESKTOP\A.ASM 9 : Use of this instruction is not recommended.

I'm not sure what this means. Is 7 and 9 refering to the line of code?

I still haven't got the LED to do anything. I never thought this would be so frusterating. I bet I have atleast 5 or 6 hours of trying to get an led to blink! and no luck yet!

Can I add a loop in the code so that the led strobes insted of flashing twice? Can I somhow hold the pin high so I can check it for voltage with a DMM? I don't have a scope yet.
 
I'm not sure what this means. Is 7 and 9 refering to the line of code?
Yes, usually if you double click on the error message, MPLAB will show you where the related error is. It is best to fix the first error in the list and then recompile because sometimes this will make the remaining errors disappear.
I suspect these errors come from the use of the OPTION and TRIS instructions which MicroChip no longer recommends because they may be discontinued in future chips and your code will no longer be portable to the new chips.

Can I somhow hold the pin high so I can check it for voltage with a DMM? I don't have a scope yet.
Yes.... Something like this;

bsf PORT, PIN
loop
goto loop
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top