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.

Help for newbie

Status
Not open for further replies.

fmatosqg

New Member
Hi all,

I'm relatively new to PICs, but have used it before with colleagues. Now I am on my own, and I'm stuck with very basic programming. I have overall knowledge of PICs, and general programming or electronics should not be a problem.

Now i have built my own serial programmer (Programming the PIC16F84 with Linux), went to linux with both sdcc, gpasm, gpsim and picprog, and tried to program my 16F684A to do some led toggles based on elementary programs stealing power from this same programmer, but a no-go. And yes, I get 5V across Vss and Vdd (in fact 5.5V but I dont trust my volt meter precision).

Things i tried: a) putting a led from vpp to /MCLR so it now reads 5.0V
b) toggling portb2, portb3 and porta(various) so it should not conflict with the programmer
c) changing all references from 16F427 to 16F468A, because the original program had these info.

Now my concern is tracking the problem, so I can tell whether the chip is not alive, not working, not programmed, etc.

Here it is what it does: I read 0V at all portA, portB0~3, and -0,25V (yes, minus) at portB4, independent of the setting of output to any of this pins. From this I can understand that the chip is not driving the outputs, or else it should show at least 0,2V as any TTL would do. And, if toggling as it should, I expect it to be at least 1V

Also, 0V from osc1 and osc2. Does that mean the internal clock is NOT working?

When I read the program, it is different from the .hex file I have compiled (#cmp says 'differ: byte 3, line 1'), but when I change the program and compare to a previous that i rode before, it tells me like 'differ: byte 10, line 1', so I am not suspecting problems with usage of the programmer i built.

Should I try powering externally without the programer plugged in? What is the most basic electronical test that I can do to tell if the most basic program is working, or at least the CPU is running? All i have is a pair of transistors, leds, resistors, and a volt meter.

I am thinking about buying an 16F427 or 16F84, they seem more popular to get elementary code to test on. Should it help me?

Is there a way to debug the chip while it is running? So at least I know it is ticking inside?

Thanks


=========================
main

bsf STATUS, RP0 ; Select Bank 1
bcf TRISA ^ 0x080, 0x1 ; Enable RB1 for Output

bcf STATUS, RP0 ; Select Bank 0

toggle
bsf PORTA, 1
bcf PORTA, 1

goto toggle
 
Neither of the chips you refer to exist (16F427 & 16F468A).

When you work out which chip you are using look in C:\Program Files\Microchip\MPASM Suite\Template\Code and find the template file for your chip. This contains vital things like the config settings.

Mike.
 
Hi,

Thank you mike, I made some typos, I was referring to 16F627 and 16F648A.

I could make my leds toggle this night, after taking a closer look at easy schematics. What happened is that I needed the RC around OSC2, after I soldered that everything worked fine. I knew it when got readings of about 3V in both the OSC1 and PORTA, then just put the led back.

Anyway, that was a hit for me, because needed only a small fix.

Fabio.
 
Both of those chips have an internal oscillator. If you open the template file I referred to earlier you will see how to use the include and config directives.

Mike.
 
Do you mean I can make the pic tick replacing the RC network on pin osc1 with a small piece of code? And how fast can I get with this SW solution? I have heard that to achieve 40MHz I would need a crystal.

That looks nice, now I use linux for development, but maybe I install some microchip tools just to get these files you mentioned.

Anyway, now I my clock is beating veery slow such that I can see the leds blink. I didn't have any capacitor below 1000pF around, so I just used a 100nF+1kOhm that I had.

Fabio.
 
Do you mean I can make the pic tick replacing the RC network on pin osc1 with a small piece of code? And how fast can I get with this SW solution? I have heard that to achieve 40MHz I would need a crystal.

Internal oscillators are generally 4MHz, switchable to 32KHz, some more modern ones have 8MHz as well.

Max clock speed for 16F series chips is usually 20MHz, many of the 18F series will do 40MHz using a 10MHz crystal and an internal PLL multiplier.

That looks nice, now I use linux for development, but maybe I install some microchip tools just to get these files you mentioned.

Anyway, now I my clock is beating veery slow such that I can see the leds blink. I didn't have any capacitor below 1000pF around, so I just used a 100nF+1kOhm that I had.

PIC's will work from DC up to (and usually above) their maximum rating.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top