PDA

View Full Version : Beginer Help!



MINHLE
- 30th June 2008, 14:17
I WROTE A BLINK PROGRAM USING 16F628,

CMCON = 7 ; turn comparator off

; the osc used is INTRCIO in the OSCILATOR SELEC OF MELAB

LOOP ; this part copy form melab introduction

HIGH PORTB.7 ; make port B7 high
PAUSE 500 ; pause for 0.5 sec

LOW PORTB.7 ; make port B7 low
PAUSE 500

GOTO LOOP
END

it does not work. the input voltage is 5V ( to the pin 14), the output is 1.0 V for each output pin , no external osc connected; (i HAVE TRIED FOR 3 DIFFERENT IC'S, AND DIFFERENT INTERNAL OSC'S

ANY HELP I DO APPRE.

Melanie
- 30th June 2008, 14:30
And how have you got MCLR connected?

Redo your program adding these two lines at the top...



@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
@ DEVICE pic16F628, MCLR_OFF

Norbac
- 30th June 2008, 14:41
Just pull up the MCLR pin with a 4.7k resistor. Or change the "MCLR Pin function" to "Input pin" on the meProg Configuration section.

See you!!!!!!!!!

MINHLE
- 30th June 2008, 14:46
Thanks, I Will Try,

MINHLE
- 30th June 2008, 15:27
THANKS BOTH OF YOU,

it still does not work
I SEE SOME THINGS HERE:

THERE ARE TWO ILLEGAL OPCODES FOR F16F628 when running the program,

THE MEPROG CONFIGURATION IS IRRELEVANT TO THE PROGRAM?:

1- DEVICE .....INTRC_OSC_NOCLKOUT (set up on osc type on the configuration?)
2- DEVICE.....MCLR_OFF (MCLR_IN set up on the reconfiguration),

(the PICF628 is selected)

MINHLE
- 30th June 2008, 15:42
I add @ DEVICE PIC16F628, __config 0x3D18 to use internal OSC.

and remove @ DEVICE PIC16F628, INTRC_OSC_NOCLKOUT,

it does not work!!

mackrackit
- 30th June 2008, 16:34
Find the 16F628.inc file in your PBP directory. The comment out the fuse lines with a ';'


NOLIST
ifdef PM_USED
LIST
include 'M16F62x.INC' ; PM header
; device pic16F628, xt_osc, wdt_on, pwrt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F628, r = dec, w = -302
INCLUDE "P16F628.INC" ; MPASM Header
; __config _XT_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
Then use the config statements from Melanie.
http://www.picbasic.co.uk/forum/showthread.php?t=543
Read post #1 and #5.

MINHLE
- 30th June 2008, 18:15
thanks for your attention.

I did check in the .inc of the 16F628, all defined terms are there.
should i have a little bit of time to understand and figure out

thanks again

Minh Le

MINHLE
- 1st July 2008, 03:39
hi MACKRACKIT

it works now.

as you suggested: i change IN THE .INC FILE


IFDEF PM_USED
......

DEVICE PIC16F628 INTRC_OSC_NOCLKOUT, MCLR_OFF, ....

XALL

....

MY QUESTION IS I KEEP THE ORIGINAL INC. FILE , IN THE PROGRAM I ADD AS MELANIE SUGGESTED

@DEVICE PIC16F628 INTRC_OSC_NOCLKOUT
......

IN THIS CASE THE INC. FILE OF 16F628 SHOULD BE CALLED AND EXECUTE THE INCLUDED FUNCTION OF INTRC_OSC_NOCLKOUT AND MCLR_OFF.

BUT NOTHING HAPPENED!!!

mackrackit
- 1st July 2008, 08:31
Not sure I understand the question now.

Keep the *.inc files as Pic Basic will look for it even if it is not being used.

Most of the time I set the *.inc file the way I want the configuration to be. Others like to do it in their code.

If you set the config in code the lines in the *.inc need to be commented (rem) out, if not you will get errors.

If I understand when you were using the*.inc file nothing happened. There may be another setting in that file that was causing the problem. ??? How is MCLR set in the *.inc?

MINHLE
- 1st July 2008, 21:11
hi,

sure I have to return the orignal config. but first of all i should see how it looks like.

the MCLR was set to off (MCLR_OFF), I try another way to test the circuit in oder to bring back to the original setting.

thanks for your attention

Minh LE

Archangel
- 2nd July 2008, 03:19
hi,

sure I have to return the orignal config. but first of all i should see how it looks like.

the MCLR was set to off (MCLR_OFF), I try another way to test the circuit in oder to bring back to the original setting.

thanks for your attention

Minh LE

Hi Minh LE,
Actually you do not have to return it to the default settings. The Default settings are there, mostly to help beginning programmers get started, as they likely do not know how to set them in code. You have 3 choices, return them to default settings, comment them out and always set them in your main code, or set them to the setting you use most often and do not include them in your code.
JS

MINHLE
- 3rd July 2008, 11:04
Hi, Mackrakit,

I did a mistake:

when add the @device pic16f628 intrc_osc_noclkout
and @device 16f628 mclr_off

in the conf. window should be :

1- oscillator: intrc clockout
2- Mclr input pin

-------------------------------------------------
for several ouput pins @ port B, the story is different. I am trying to read in the data sheet of the 16f628.

regards,
Minh le

mackrackit
- 3rd July 2008, 14:44
Are you looking at the TRIS statement? If so, start by putting it near the beginning of your code.

TRISB = %00000000 ' makes all PORT B pins output
TRISB = %11111111 ' makes all PORT B pins input
TRISB = %00000011 ' makes pins B.0 and B.1 inputs, the rest outputs.

MINHLE
- 5th July 2008, 03:57
Thanks For Your Help,
It Is As Simple As Assembly Language. And It Is Easy For Me To Follow.

The Codes That Appear In The Program Of Blinking Port B Like This:
Trisb, Pr2, Ccpr1l, Ccp1con, T2con. These Scared Me.

So I Can Continue Now With The Simple Progrmams

Thanks Agiain,

Minh Le