CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Need program example/help for PIC12F675 with ver. 3.221

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Futterama



Joined: 17 Oct 2005
Posts: 98

View user's profile Send private message

Need program example/help for PIC12F675 with ver. 3.221
PostPosted: Mon Oct 17, 2005 1:21 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Oct 17, 2005 1:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 1:37 am     Reply with quote

You have MCLR enabled. Did you tie it high?
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Oct 17, 2005 1:42 am     Reply with quote

What debugger/programmer are you using?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 1:42 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Oct 17, 2005 2:33 am     Reply with quote

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








PostPosted: Mon Oct 17, 2005 3:14 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 3:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 3:18 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 3:22 am     Reply with quote

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







PostPosted: Mon Oct 17, 2005 3:43 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 8:14 am     Reply with quote

Futterama wrote:
Quote:

What is the MCLR option anyway?
What does it mean when it's on?
What does it mean when it's off?


http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_03chapter.htm

Humberto
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group