View previous topic :: View next topic |
Author |
Message |
Futterama
Joined: 17 Oct 2005 Posts: 98
|
Need program example/help for PIC12F675 with ver. 3.221 |
Posted: Mon Oct 17, 2005 1:21 am |
|
|
Hello forum,
I'm having trouble with the PIC12F675. I wanted to start off with a simple blink-led program, and I used the wizard to generate the basic codes.
But when I download the hex-file to the PIC, nothing happens.
I'm using internal osc.
My code:
blinkled.c
Code: |
#include "blinkled.h"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
output_high(PIN_A4);
delay_ms(500);
output_low(PIN_A4);
delay_ms(500);
}
}
|
blinkled.h
Code: |
#include <12F675.h>
#device adc=8
#fuses NOWDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT
#use delay(clock=4000000)
|
I'm sure the PIC, programmer and board is working, because I can easily make the same program with PicBasic, and everything works ok with that language.
I'm using version 3.221 of the CCS compilers and IDE.
Please advise :-)
Regards,
Futterama |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Mon Oct 17, 2005 1:28 am |
|
|
You have to start your program either by clicking a green go button on the debugger window or "Run program" button on the ICD-U software. |
|
|
Eugeneo
Joined: 30 Aug 2005 Posts: 155 Location: Calgary, AB
|
|
Posted: Mon Oct 17, 2005 1:37 am |
|
|
You have MCLR enabled. Did you tie it high? |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Mon Oct 17, 2005 1:42 am |
|
|
What debugger/programmer are you using? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 17, 2005 1:42 am |
|
|
1. Do you have a pullup resistor to Vdd on the MCLR pin ?
2. Can you read program memory with your programmer, and
tell us what hex value is programmed at address 0x3FF ?
3. What programmer and programmer software are you using ?
What versions ? |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Mon Oct 17, 2005 2:33 am |
|
|
Eugeneo wrote: | You have MCLR enabled. Did you tie it high? |
PCM programmer wrote: | 1. Do you have a pullup resistor to Vdd on the MCLR pin ? |
He probably does have a pull-up, because his PicBasic program works. |
|
|
Guest
|
|
Posted: Mon Oct 17, 2005 3:14 am |
|
|
PCM programmer wrote: |
2. Can you read program memory with your programmer, and
tell us what hex value is programmed at address 0x3FF ?
|
Can you disable the compiler from generating
0004: CALL 3FF
0005: BSF 03.5
0006: MOVWF 10
0007: MOVLW 00
0008: MOVWF 0A |
|
|
Futterama
Joined: 17 Oct 2005 Posts: 98
|
|
Posted: Mon Oct 17, 2005 3:16 am |
|
|
Hi,
Actually, I had no pullup from MCLR to Vdd. The reason it worked in PicBasic was because MCLR was disabled in that program.
I didn't notice the MCLR - on or off.
I put a 10k pullup on MCLR and the program still didn't work.
I disabled the MCLR in my C program, and it works.
Thanks.
What is the MCLR option anyway?
What does it mean when it's on?
What does it mean when it's off?
What pullup value should be used for MCLR when it's on?
Regards,
Futterama |
|
|
Futterama
Joined: 17 Oct 2005 Posts: 98
|
|
Posted: Mon Oct 17, 2005 3:18 am |
|
|
PCM programmer wrote: | 2. Can you read program memory with your programmer, and
tell us what hex value is programmed at address 0x3FF ? |
It says 3480. This it the OSCCAL right? |
|
|
Futterama
Joined: 17 Oct 2005 Posts: 98
|
|
Posted: Mon Oct 17, 2005 3:22 am |
|
|
Anonymous wrote: | PCM programmer wrote: |
2. Can you read program memory with your programmer, and
tell us what hex value is programmed at address 0x3FF ?
|
Can you disable the compiler from generating
0004: CALL 3FF
0005: BSF 03.5
0006: MOVWF 10
0007: MOVLW 00
0008: MOVWF 0A |
What is that all about? |
|
|
Ttelmah Guest
|
|
Posted: Mon Oct 17, 2005 3:43 am |
|
|
Futterama wrote: | Anonymous wrote: | PCM programmer wrote: |
2. Can you read program memory with your programmer, and
tell us what hex value is programmed at address 0x3FF ?
|
Can you disable the compiler from generating
0004: CALL 3FF
0005: BSF 03.5
0006: MOVWF 10
0007: MOVLW 00
0008: MOVWF 0A |
What is that all about? |
This is the code to read the OSCCAL value from program memory, and write it into the chip's control register. Without this, the accuracy of the oscillator will be poor. However if the value at 0x3FF gets destroyed by the programmer (most _should_ save this value), the code can result in the processor gtting hung.
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
|
|