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 support@ccsinfo.com

Spot the error (should be easy)

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







Spot the error (should be easy)
PostPosted: Fri Sep 12, 2008 6:49 pm     Reply with quote

Hello,

I am trying to compile a very (very) simple program to learn the C (PCM V4) compiler. I know a bit of assembly using MPLAB already.

I am using a PIC16F690 on the Pickit2 low pin count demo board and using a Pickit2 for programming.

When I flash the chip with a program written in assembly, it works as expected (lights are flashing).

When I compile and flash the following program, my light stays on solid.

Code:
#include "D:\Projects\PIC\test2\test2.h"

void main()
{
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_oscillator(False);

   set_tris_c(0x00);

while(1)
   {
   output_high(PIN_C0);
   delay_ms(1000);
   output_low(PIN_C0);
   delay_ms(1000);
   }
}


The header (compiler generated) looks like so,

Code:
#include <16F690.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC                    //Internal RC Osc
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOPUT                    //No Power Up Timer
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


I thought maybe the WDT or brownout was tripping, so I turned those off. Once programmed the LED on port C0 turns on and stays on.

Ideas? Im running out. Are there instructions for loading a C program into MPLAB to use the simulator? I have not found them.

Thank you.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 12, 2008 8:03 pm     Reply with quote

See this test program:
http://www.ccsinfo.com/forum/viewtopic.php?t=34785&start=3
jfarkas



Joined: 07 Dec 2006
Posts: 4
Location: Croatia

View user's profile Send private message

Datasheet
PostPosted: Sat Sep 13, 2008 3:52 am     Reply with quote

This could be problem....

#FUSES INTRC //Internal RC Osc
#use delay(clock=20000000) ???????????
Gerhard



Joined: 30 Aug 2007
Posts: 144
Location: South Africa

View user's profile Send private message Send e-mail

PostPosted: Sat Sep 13, 2008 8:26 am     Reply with quote

The internal oscilator on that pic is running at 4M. Just change that line

Code:
#FUSES INTRC //Internal RC Osc
#use delay(clock=20000000)


To
Code:
#FUSES INTRC //Internal RC Osc
#use delay(clock=4M)
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