PDA

View Full Version : Cant get it to work



bearpawz
- 7th April 2010, 20:38
Ok, I dont know WHAT in the world is going wrong here. I can not even get so much as a simple blink to happen. Here is the code:



DEFINE OSC 8 ' 8 Mhz Oscillation
OSCCON = $70 ' Oscilator Config reg.

start:
High 0
pause 1000
low 0
pause 1000
goto start


Compiles fine. I am using picbasic 2.60, Microcode Studio 3.0.0.5, and IC_prog 1.06B.

1. Compile the program, get a hex file
2. Load up the hex file in IC-Prog. Im using 16F818 or 16F819. I have tried like 10 chips and none will work and I doubt they are ALL bad.
3. Selecting IntRC for oscilator in ICPROG
4. Config is as follows:
- WDT = true
- PWRT = true
- MCLR = True
- BODEN = True
- LVP = False
- CPD = False
- Debugger = False
- CCPMX = True

I program it, it verifies.. so far so good..

yet when I plug it up to the most basic circuit, I get NOTHING. Its like the chip is just not doing anything at all. Ive even included power indicator LED's to make sure it is getting power etc. What in the world am I missing here? Im sure its something so incredibly simple I just cant see it... (We've all been there Im sure)

mackrackit
- 7th April 2010, 21:01
Is MCLR pulled HIGH?

aratti
- 7th April 2010, 21:14
First thing to do is to put all pins to digital, since you are not going to use ADC.

ADCON1 = 7


Second thing to do is to fix what you want to do with these digital pins. Outputs? or Inputs? Now since you want to flash one led then we will set all as outputs, setting the TRIS register.

TRISA = %00000000
TRISB = %00000000

And place all to low level

PortA = 0
PortB = 0


Now your code


start:
High PortB.0
pause 1000
low PortB.0
pause 1000
goto start

Here I assume you have connected your led with 330 Ohms resistor in series to portB.0, which is pin 6. If you have use a different pin then change the reference.

You can also use ALIAS giving a name to the port, but you must declare it before to use it.

Led var PortB.0

start:
High Led
pause 1000
low Led
pause 1000
goto start


Will do the same as the previuos code. Hope it will help.

I didn't check if your oscillator setting is correct or not, I assume that is correct.

Al.

bearpawz
- 7th April 2010, 21:15
http://home.comcast.net/~bearpawz/blink_schematic.jpg

malc-c
- 7th April 2010, 21:41
According to the datasheet ( http://ww1.microchip.com/downloads/en/devicedoc/39598e.pdf ) pin 4 is MCLR - from the schematic it seems you have pin 3 (RA4) pulled high via a resistor.

You also don't show any timing crystal, so assume you are using the internal osc



The PIC16F818/819 devices include an internal
oscillator block which generates two different clock
signals; either can be used as the system’s clock
source. This can eliminate the need for external
oscillator circuits on the OSC1 and/or OSC2 pins.
The main output (INTOSC) is an 8 MHz clock source
which can be used to directly drive the system clock. It
also drives the INTOSC postscaler which can provide a
range of clock frequencies from 125 kHz to 4 M


Therefore you might need to configure the PIC for internal OSC

FOSC2:FOSC0: Oscillator Selection bits
111 = EXTRC oscillator; CLKO function on RA6/OSC2/CLKO pin
110 = EXTRC oscillator; port I/O function on RA6/OSC2/CLKO pin
101 = INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on
RA7/OSC1/CLKI pin
or
100 = INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin
011 = EXTCLK; port I/O function on RA6/OSC2/CLKO pin
010 = HS oscillator
001 = XT oscillator
000 = LP oscillator

Hope that helps

bearpawz
- 7th April 2010, 21:49
Yeah, thats just an error in my schematic diagram. I have the resistor on pin 4 not pin 3. Im prety sure my problem is somewhere in the config fuses. Its been a while since Ive played with any of this but Ive writen a bunch of far more complex programs than this and have had them work. If only I could find the code maybe I would see what I am missing.

aratti
- 7th April 2010, 21:57
I have the resistor on pin 4 not pin 3.

That is fine, but from your schematic the resistor (hope 10 KOhms) is connected to Vss, which is a pulldown not a pullup. Connect the resistor to Vdd.

In your schematic you are showing Vdd as ground! Remember that Vdd is + 5 Volts and Vss is ground.

Al.

bearpawz
- 7th April 2010, 23:11
Yeah, just my mistake trying to draw up a quick schematic. I fixed it though and its now hooked up as the new schematic shows. And yes, now using port B.4 now (pin 7) only because it makes the circuit on the breadboard cleaner. was going to try and take pictures of it but my camera sucks... and it still is not working at all. I am stumped. I guess its possible that I have a bunch of bad chips so I guess I will order more and see if that helps at all. I still think its a fuse thing some how though, even though I have it set to internal osc.

Does anyone know if there is a better programer software out there than IC-prog (preferably freebe) that works with JDM programmers?

mackrackit
- 7th April 2010, 23:35
I still think its a fuse thing some how though, even though I have it set to internal osc.
Then show us how you have the *.inc file setup or how you are doing it in code space.

Please do not say you are setting them with icprog...

aratti
- 7th April 2010, 23:39
I guess its possible that I have a bunch of bad chips

Expecially if you have powered them with reverse supply.

You show 1K resistor in series with leds. This is too much!

Let's make the resistor calculation together:
It is safe enough to assume 1.7 voltage drop for non-high-brightness red led, so 5 volts - 1.7 volts (led drop) = 3.3 volts

10 miliamps is the normal forward current for a standard led so:

3.3/0.01 = 330 Ohms

With 1K you will have a very weak led since: 3.3/1000= 0.00333 = 3.3 milliAmps
just 1/3 of the current required.

Al.

malc-c
- 8th April 2010, 00:05
Assuming you have wired everything correctly, and not as per your original sketch then it could be that either your JDM programmer isn't programmingn the PICS or IC-Prog is not setting the config correctly.

The only other program I know that might work and is free is Win-Pic 800 ( http://www.winpic800.com//index.php?option=com_content&task=blogcategory&id=18&Itemid=64 )

bearpawz
- 8th April 2010, 00:08
Hmm. let me double check this:

Yes I am using 1K. The "Power" LED seems to do just fine with the 1K but I see what your saying about the pic not having a whole lot of current. Just for gits and shiggles I removed the resistor all together comming from the pic and not so much as a blown LED... just a whole lot of nothing...

However....



Then show us how you have the *.inc file setup or how you are doing it in code space.

Please do not say you are setting them with icprog...



Actually, yes.. that is exactly how I am setting the fuses. Is that wrong?




Assuming you have wired everything correctly, and not as per your original sketch then it could be that either your JDM programmer isn't programmingn the PICS or IC-Prog is not setting the config correctly.


That was my original assumtion as well. I have done all kinds of little "tests" though (writing data in EEPROM memory and reading it back, etc). I dont *THINK* its the programmer hardware but I would bet my life it isnt either. For all I know its a bunch of bad chips... though I have had no luck with 16F88 chips either and those I have here are brand new in the tube.

mackrackit
- 8th April 2010, 00:16
Actually, yes.. that is exactly how I am setting the fuses. Is that wrong?

EEEH, not really wrong, just not the best way. Find where you can turn this feature off and read this.
http://www.picbasic.co.uk/forum/showthread.php?t=543

PBP by default reads the *.inc file for the chip that is in the PBP directory. You can modify the *.inc to the setting you want or modify it so the configs can be set in code space.
The difference between the two is a personal preference.

mackrackit
- 8th April 2010, 00:25
For the 16F88, this is what the beginning of your code should look like if you are setting the configs in code space and want the ADC off, MCLR as an input, internal 4MHz.


DEFINE OSC 4
OSCCON = %01100000
@ __config _CONFIG1, _INTRC_IO & _WDT_OFF & _LVP_OFF & _MCLR_OFF &_CP_OFF
ANSEL = %00000000

HenrikOlsson
- 8th April 2010, 06:33
Hi,
I don't know, perhaps I'm way late here but your original program reads HIGH 0 and LOW 0 which may work on a BASICStamp but I don't think it works with PBP - even after including the BS1/2 defs - which you don't seem to have done anyway.

Al, covered it in his program by changing the code to HIGH PORTB.0 etc but then in a later message you say you're using PORTB.4 instead. Did you change the code so it reads HIGH PORTB.4 etc?

/Henrik.

malc-c
- 8th April 2010, 09:21
Hi,
I don't know, perhaps I'm way late here but your original program reads HIGH 0 and LOW 0 which may work on a BASICStamp but I don't think it works with PBP - even after including the BS1/2 defs - which you don't seem to have done anyway.etc?

/Henrik.

Good point,

The original code doesn't even state what to high and low, what port, what variable etc. Barepawz can you post your entire code as it now stands?

Given the suggestions, it should now set the config bits via the inc file, turn all ports digital, turn off A/D, and flash your LED.

Oh and it's not advisable to drive a LED without any series resistor, this will allow the LED to draw as much current as it needs, which could be more than the PIC can provide. My EasyPIC5 board uses 1K resistors with "normal" 3mm defuse red LEDS, which work even though they shouldn't according to Al's formula, possibly as the forward current is probably 20ma rather then the 10ma used in the example. If you're using one of the Ultra-bright LEDS then use the formula in Al's post along with the data sheet for the LEDs you are using.

Acetronics2
- 8th April 2010, 09:52
Hi,

This ( as ARatti finished it ) :



'************************************************* ***************
'* Name : BPWZ.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 08/04/2010 *
'* Version : 1.0 *
'* Notes : 16F819 *
'* : *
'************************************************* ***************
DEFINE OSC 8 ' 8 Mhz Oscillation
OSCCON = $70 ' Oscilator Config reg.

ADCON1 = 7

TRISA = %00000000
TRISB = %00000000

PortA = 0
PortB = 0

start:
High 0
pause 1000
low 0
pause 1000
goto start


Makes PortB.0 blink @ 2 Hz ... Only if you use an external 8 Mhz Xtal ... as PBP Defaults to HS Osc for the Config. ( see #14 from Dave )

you must add :



@ device PIC16F819,INTRC_OSC_NOCLKOUT, WDT_ON, PWRT_ON, MCLR_ON, protect_OFF, LVP_OFF


to the top of the listing to get INTRC Oscillator work, if MCS using. Then no need to define the options by hand in IC Prog ...

a look to manual $ 4.11 will show how "numbers only" work as port pins defining ...

is the great mysterious code problem solved, now ???

Alain

HenrikOlsson
- 8th April 2010, 15:21
Hmm, I see I've completely missed (or perhaps forgotten) that HIGH 0 valid, you (re)learn something everyday. Still, I'd say it's "better" (not function wise but for readability) to actually say HIGH PORTB.0

Thanks for pointing mo that Alain, let's hope the OP gets this going now!

/Henrik.

bearpawz
- 8th April 2010, 15:49
Im at work right now so dont have access to the entire code. I did make this change to the main routine:



Start:
PortB=0
pause 500
portB= $FF
pause 500
Goto start



In theory this should toggle all the pins on portB. Unfortunatly, still getting a whole lot of nothing. Im prety sure there is either something wrong with fuse config (will look into the above suggestions when I get home tonight), or maybe its a hardware problem.

Acetronics2
- 8th April 2010, 17:45
will look into the above suggestions when I get home tonight


I think It's much better ...

Alain

bearpawz
- 9th April 2010, 02:11
Well, I think at this point I have tried everything except brand new out of the tube microcontrollers. There is one factor in play here I didnt think of until just recent: Im using a very old laptop, and windows 98SE. I really dont think this is the problem but I have never had this kind of issue before so maybe it is. It appears to me as if the pic is being flashed correctly because I can flash test data into the EEPROM memory, and it will be read back correctly. It may be time to just break down and buy a better programming solution. For now Im sort of giving up.

jellis00
- 9th April 2010, 03:28
Does anyone know if there is a better programer software out there than IC-prog (preferably freebe) that works with JDM programmers?

I also use MCS with PBP version 2.6, but I use a PICKIT2 as my programmer rather than the IC-prog. This development configuration lets me compile and program the chip in one step without creating a .hex file and downloading it into the programmer like most configurations. My configuration is reliable and works great. PICKIT2 is worth the $50 just to simplify the development environment. Plus if you then place a 6-pin header on all your board designs, you can connect directly to your final board configuraiton for re-programming in the field.

Acetronics2
- 9th April 2010, 09:05
HI, BPWZ

I can't resist ...

http://www.picbasic.co.uk/forum/showpost.php?p=31095&postcount=6

Alain

malc-c
- 9th April 2010, 09:21
If you have access to another PC then try using the programmer with that. It is a well documented fact that serial ports on a lot (if not most) laptops lack the power that JDM programmers need to generate the programming voltages.

I can remember having loads of programming issues when I was using a commercial version of this type of programmer with IC-Prog. I've since purchased an EasyPIC board which has a built in programmer and software - which I must say has never let me down.

If your funds can't stretch to an EasyPIC board, then I too would suggest you look at the picKit2 programmer.