PDA

View Full Version : Help Pic16f628a



gadelhas
- 26th August 2008, 20:24
Hi everyone;

I'm trying to program a PIC16F628A with internal oscilator and no MCLR Resistor, however, it does not Work, and i donīt know what i'm doing wrong; can you help me ?

Here goes the code;

@ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT
@ DEVICE pic16F628A, WDT_ON
@ DEVICE pic16F628A, PWRT_ON
@ DEVICE pic16F628A, MCLR_OFF
@ DEVICE pic16F628A, BOD_OFF
@ DEVICE pic16F628A, LVP_OFF
@ DEVICE pic16F628A, CPD_OFF
@ DEVICE pic16F628A, PROTECT_OFF


'76543210
TRISA = %00000000
TRISB = %00001110
CMCON = 7
VRCON = 0



Led1 VAR TRISB.6
Led2 VAR TRISB.5
Led3 VAR TRISB.4


Main:
HIGH Led1
PAUSE 2000
LOW Led1
HIGH Led2
PAUSE 2000
LOW Led2
HIGH Led3
PAUSE 2000
LOW Led3
Goto Main


END


Regards
Gadelhas

Melanie
- 26th August 2008, 20:57
You wrote INTOSC_OSC_NOCLKOUT

Shouldn't it be INTRC_OSC_NOCLKOUT

Unfortunately, mistakes and typo's in DEFINE statements rarely produce compiler errors, so it's worthwhile double checking you have those correct.

Where can you find the correct settings you might ask... see this thread...

www.picbasic.co.uk/forum/showthread.php?t=543

gadelhas
- 26th August 2008, 21:17
You wrote INTOSC_OSC_NOCLKOUT

Shouldn't it be INTRC_OSC_NOCLKOUT

Unfortunately, mistakes and typo's in DEFINE statements rarely produce compiler errors, so it's worthwhile double checking you have those correct.

Where can you find the correct settings you might ask... see this thread...

www.picbasic.co.uk/forum/showthread.php?t=543


Melanie; thanks for answer, but unfortunately, i made that change, but still not working!

Can you see if theres anything wrong or missing, again?

Regards
Gadelhas

Archangel
- 26th August 2008, 22:11
Melanie; thanks for answer, but unfortunately, i made that change, but still not working!


Hi gadelhas,
Could you please define " not working"?

gadelhas
- 26th August 2008, 22:14
Hi gadelhas,
Could you please define " not working"?

Hi Joe;

Donīt do nothing, all leds off.

Regards
Gadelhas

Archangel
- 26th August 2008, 23:15
I found your problem.


@ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT
@ DEVICE PIC16F628A, WDT_ON
@ DEVICE PIC16F628A, PWRT_ON
@ DEVICE PIC16F628A, MCLR_OFF
@ DEVICE PIC16F628A, BOD_OFF
@ DEVICE PIC16F628A, LVP_OFF
@ DEVICE PIC16F628A, CPD_OFF
@ DEVICE PIC16F628A, PROTECT_OFF


'76543210
TRISA = %00000000
TRISB = %00001110
CMCON = 7
VRCON = 0
DEFINE OSC 4

Led1 VAR PORTB.6
Led2 VAR PORTB.5
Led3 VAR PORTB.4


Main:
HIGH Led1
PAUSE 2000
LOW Led1
HIGH Led2
PAUSE 2000
LOW Led2
HIGH Led3
PAUSE 2000
LOW Led3
Goto Main


END

Simple mistake on your variables you wrote
Led1 VAR TRISB.6
Led2 VAR TRISB.5
Led3 VAR TRISB.4

should be :
Led1 VAR PortB.6
Led2 VAR PortB.5
Led3 VAR PortB.4

gadelhas
- 26th August 2008, 23:22
I found your problem.


@ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT
@ DEVICE PIC16F628A, WDT_ON
@ DEVICE PIC16F628A, PWRT_ON
@ DEVICE PIC16F628A, MCLR_OFF
@ DEVICE PIC16F628A, BOD_OFF
@ DEVICE PIC16F628A, LVP_OFF
@ DEVICE PIC16F628A, CPD_OFF
@ DEVICE PIC16F628A, PROTECT_OFF


'76543210
TRISA = %00000000
TRISB = %00001110
CMCON = 7
VRCON = 0
DEFINE OSC 4

Led1 VAR PORTB.6
Led2 VAR PORTB.5
Led3 VAR PORTB.4


Main:
HIGH Led1
PAUSE 2000
LOW Led1
HIGH Led2
PAUSE 2000
LOW Led2
HIGH Led3
PAUSE 2000
LOW Led3
Goto Main


END

Simple mistake on your variables you wrote
Led1 VAR TRISB.6
Led2 VAR TRISB.5
Led3 VAR TRISB.4

should be :
Led1 VAR PortB.6
Led2 VAR PortB.5
Led3 VAR PortB.4


Hi Joe;

I simple just canīt belive it; what a stupid mistake. I never do that.

It's allready working. Thanks for everthing.

Regards
Gadelhas