PDA

View Full Version : pic16f628a issue



Bigandrewgold
- 27th April 2012, 22:10
So I am trying to write a hello world program of sorts for a 16f628a chip. I have a led hooked up to portb 3. Here is the code that is not working


Main:
High PortB.3
pause 100
Low PortB.3
pause 100
goto Main

The led is not turning on. Why is this not working?

c_moore
- 27th April 2012, 22:35
Do you have PortB set as output? You need TrisB.3 = 0 in your code.

Bigandrewgold
- 28th April 2012, 02:18
Do you have PortB set as output? You need TrisB.3 = 0 in your code.well I didnt, but even with that code at the top it does not work

Demon
- 28th April 2012, 04:15
What config settings did you use?

What PBP version do you have?

PM or MPASM assembler?

Robert

aerostar
- 28th April 2012, 07:53
How is your led connected, and what resistor value are you using for it ?

Bigandrewgold
- 28th April 2012, 18:18
What config settings did you use?

What PBP version do you have?

PM or MPASM assembler?

Robertwhat is a config value?
2.5 if I remember right
mpasm

Bigandrewgold
- 28th April 2012, 18:19
How is your led connected, and what resistor value are you using for it ?If i remember right it is connected to the positive end, then the negative end is grounded, and there is no resistor. But I know that the configuration is correct

Demon
- 29th April 2012, 05:19
Technically, you're supposed to put a current-limitting resistor along with an average LED with 5 VDC; most use 330ohms. Does the LED still work on 5 VDC and a resistor? Confirming it isn't burnt is a good start.

Basics on Configs here:
http://www.picbasic.co.uk/forum/showthread.php?t=543

Some overview on what files are used (I have v2.60, so it's about the same as 2.50 - the syntax for 16F is just a bit different):
http://www.picbasic.co.uk/forum/showthread.php?t=15982

Robert


EDIT: Look at top right, try CONFIG 16F628A in Advanced Search.

Here is one thread that came up:
http://www.picbasic.co.uk/forum/showthread.php?t=9794

Bigandrewgold
- 30th April 2012, 03:07
Technically, you're supposed to put a current-limitting resistor along with an average LED with 5 VDC; most use 330ohms. Does the LED still work on 5 VDC and a resistor? Confirming it isn't burnt is a good start.

Basics on Configs here:
http://www.picbasic.co.uk/forum/showthread.php?t=543

Some overview on what files are used (I have v2.60, so it's about the same as 2.50 - the syntax for 16F is just a bit different):
http://www.picbasic.co.uk/forum/showthread.php?t=15982

Robert


EDIT: Look at top right, try CONFIG 16F628A in Advanced Search.

Here is one thread that came up:
http://www.picbasic.co.uk/forum/showthread.php?t=9794the led works, and I have been told by 2 friends of mine familiar with what I am doing that I dont need a resistor because of my setup.

But even after reading that stuff I can still not get this working for the life of me. Here is my, still broken, code.

@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _LVP_OFF

Define OSC 4
CMCON = 7
VRCON = 0




PortA=0
TRISA=0000
TRISB = 0000
PortB = 0000


Main:
High PortB.3
high PortA.1
pause 1000
Low PortB.3
low PortA.1
pause 1000
goto Main




Also, I just found these fuse settings in my programmer, should one of these settings be different?
http://i.imgur.com/nBq5u.jpg

Demon
- 30th April 2012, 19:35
Did you comment out the config in the Include file as described here:
http://www.picbasic.co.uk/forum/showthread.php?t=15982

The config settings in your programmer should be ok. Compare them with what you put in your code.

What happens exactly, do you get error messages?
Compiles ok but no activity on circuit?

Robert

Bigandrewgold
- 1st May 2012, 01:50
Did you comment out the config in the Include file as described here:
http://www.picbasic.co.uk/forum/showthread.php?t=15982

The config settings in your programmer should be ok. Compare them with what you put in your code.

What happens exactly, do you get error messages?
Compiles ok but no activity on circuit?

Robertthe config settings look the same.

it compiles and programs perfectly, but nothing happens on the circuit.

Demon
- 1st May 2012, 02:16
Look at Archangel's code here:
http://www.picbasic.co.uk/forum/showthread.php?t=6061&highlight=16f628a

He has these also (for 16F628 - not sure if it applies to you):

T1CON = %00000011
OPTION_REG = %01010111

What if you disable BODEN and PWRTE?

What about your voltage, it is at 5V right?

I don't use the low voltage 16F628A, I used the regular 16F628.

Robert

P.S.: To get your code to come out right (missing %), hover your mouse over the A icon at far left when you post, you want to be in SOURCE mode, not WYSIWYG.


EDIT: What about the resistor on MCLR?
http://www.picbasic.co.uk/forum/showthread.php?t=16188
His code works for 16F628A and internal oscillator.
Note he is using PM instead of MPASM, so his CONFIG syntax is a bit different.
He used CLKOUT instead of NOCLKOUT, not sure what difference that makes.

Can you post a drawing of your circuit, a JPG from Paintbrush would be fine.

Bigandrewgold
- 2nd May 2012, 00:31
Look at Archangel's code here:
http://www.picbasic.co.uk/forum/showthread.php?t=6061&highlight=16f628a

He has these also (for 16F628 - not sure if it applies to you):

T1CON = %00000011
OPTION_REG = %01010111

What if you disable BODEN and PWRTE?

What about your voltage, it is at 5V right?

I don't use the low voltage 16F628A, I used the regular 16F628.

Robert

P.S.: To get your code to come out right (missing %), hover your mouse over the A icon at far left when you post, you want to be in SOURCE mode, not WYSIWYG.


EDIT: What about the resistor on MCLR?
http://www.picbasic.co.uk/forum/showthread.php?t=16188
His code works for 16F628A and internal oscillator.
Note he is using PM instead of MPASM, so his CONFIG syntax is a bit different.
He used CLKOUT instead of NOCLKOUT, not sure what difference that makes.

Can you post a drawing of your circuit, a JPG from Paintbrush would be fine.

Got it working, I added some code from that thread and disabled boden and pwrte, I dont know what exactly did it but it works. And incase you were wondering, it is powered by a 3v source and I do not have a resistor anywhere/

But if anyone in the future has this problem has this problem stumbles upon this thread, here is my code that works

@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _BODEN_OFF & _LVP_OFF

Define OSC 4


LED4 VAR PortA.1
CMCON = 7
VRCON = 0
PortA=0
PortB = %00000000
T1CON = %00000011
TRISA = 0
TRISB = %00000000








STARTMAIN:




LED4=1


PAUSE 250


LED4=0


Pause 250


GOTO STARTMAIN


END

mister_e
- 2nd May 2012, 00:38
The Brown Out detect fuse solved our problem, now look at the datasheet and see why it works...