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

Need Help with this Code on PIC18F1320

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



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

Need Help with this Code on PIC18F1320
PostPosted: Wed Mar 03, 2004 8:56 pm     Reply with quote

Hello,

I need your help regarding the code below. My problem is that when I click the run program of the ICD the first time & second time my LED blinks but when I stop the program and run again using the ICD the LED will not blink again.

I need your help if I configured correctly the PIC chip.

The code list:
Code:

#include <18F1320.h>             // MCU specific library
#fuses INTRC_IO,NOLVP,NOWDT,NOPROTECT     
#use delay (clock=8000000)       // 8MHz clock

#define LED    PIN_A2
#byte OSCCON = 0x0FD3


void led_func()
{
      output_high(LED);
      delay_ms(1000);
      output_low(LED);
      delay_ms(1000);
}


main()
{
   //OSCCON = 0b11111001;
   setup_oscillator(OSC_8MHZ);
   setup_adc_ports(NO_ANALOGS);

   while(TRUE)
   {
      led_func();
   }
}


Need your help.

Thanx
SteveS



Joined: 27 Oct 2003
Posts: 126

View user's profile Send private message

PostPosted: Thu Mar 04, 2004 9:04 am     Reply with quote

I'm using the 182320 and it seems to be working ok with the ICD-2.

I noticed you initially had:

OSCCON = 0b11111001

although commented out, I don't think it's the correct value. I use 0x72 to jump to 8Mhz.

setup_oscillator(OSC_8MHZ); generates 0x70. I'm thinking that the system clock select bits (0&1) should be 1x (binary). You may want to check that.

Check the listing to see the code seems right.

One odd thing I've noticed is that I think my timers sometimes keep running even whan I pasuse the program thru the ICD. There may be some oddities with the ICD and internal oscillators.

Oh, and I usually put a short delay after boosting the oscillator to let it settle. I think it's good practice in general to delay a bit after startup to be sure the power supply has really settled.

- SteveS
ritchie



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

PostPosted: Thu Mar 04, 2004 9:03 pm     Reply with quote

SteveS wrote:
I'm using the 182320 and it seems to be working ok with the ICD-2.

I noticed you initially had:

OSCCON = 0b11111001

although commented out, I don't think it's the correct value. I use 0x72 to jump to 8Mhz.

setup_oscillator(OSC_8MHZ); generates 0x70. I'm thinking that the system clock select bits (0&1) should be 1x (binary). You may want to check that.

Check the listing to see the code seems right.

One odd thing I've noticed is that I think my timers sometimes keep running even whan I pasuse the program thru the ICD. There may be some oddities with the ICD and internal oscillators.

Oh, and I usually put a short delay after boosting the oscillator to let it settle. I think it's good practice in general to delay a bit after startup to be sure the power supply has really settled.

- SteveS


Thank you. Its now working using the internal oscillator block at 8MHz... I just added a delay before setup_oscillator(0x72) is invoke.
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