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

Potential issue with PIC16F1823 internal oscillator

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



Joined: 26 May 2007
Posts: 14

View user's profile Send private message

Potential issue with PIC16F1823 internal oscillator
PostPosted: Wed Nov 23, 2011 3:39 pm     Reply with quote

Hello,

I've just started using CCS C after a four year hiatus. The project I'm working on uses a PIC18F2550 to communicate, via USB, to a computer and act as i2c master to communication with two PIC16F1823 slave devices. I have the software, firmware, and hardware figured out for the PIC18 but the PIC16's are causing me some problems.

I've got a PIC16F1823 wired to a ICD-U40 and the oscillator frequency reads 500kHz regardless of what I do. I've gone through the forum and other internet sites and nothing seems to make a difference. Can anybody offer me help/insight based on the below code?

I'm able to toggle outputs and write to RS232 without any issue (i2c isn't working but that is another issue, I think).

I am using CCS v4.125 for compiler and my ICD-U40 firmware is 2.91.

Header file
Code:
#include <16F1823.h>
#device ICD=TRUE
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO
#FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=16000000)
#use rs232(baud=2400, xmit=PIN_C3, rcv=PIN_C4)
#use i2c(SLAVE,SLOW,sda=PIN_A4,scl=PIN_A5,ADDRESS=0xa0)


*.c file
Code:
#include <TriggerController.h>
#int_EXT
void  EXT_isr(void)
{

}

#int_SSP
void  SSP_isr(void)
{
   printf("i2c\n");
}



void main()
{
   setup_oscillator(OSC_16MHZ|OSC_INTRC|OSC_PLL_OFF,0);
   //setup_oscillator(OSC_16MHZ|OSC_NORMAL,0);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_SSP);
   enable_interrupts(GLOBAL);
   
   printf("Hello\n");
   while(TRUE)
   {
      //TODO: User Code
      output_high(PIN_C5);
      delay_ms(10);
      output_low(PIN_C5);
      delay_ms(10);
     
   }

}

_________________
Eric
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 23, 2011 5:22 pm     Reply with quote

I tested the program below with vs. 4.125 in hardware, and it blinks the
LED at a 1 Hz rate. I programmed it with a Microchip ICD3. It's running
on a Microchip "Low Pin Count" board.
Code:

#include <16F1823.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, MCLR
#use delay(clock=16M)

//=======================================
void main()
{

while(1)
  {
   output_toggle(PIN_C0);
   delay_ms(500);
  }

}

I don't think you should depend upon CCS ICD-U40, etc., to report the
correct device frequency. Many people say that it doesn't do it correctly:
http://www.ccsinfo.com/forum/viewtopic.php?t=38312&start=2
http://www.ccsinfo.com/forum/viewtopic.php?t=44454&start=3

Just blink an LED to prove that it's running at the correct frequency.
peer9802



Joined: 26 May 2007
Posts: 14

View user's profile Send private message

PostPosted: Wed Nov 23, 2011 5:31 pm     Reply with quote

OK. I was measuring "blink times" using an o-scope and everything looked fine besides the ICD value. I will ignore it for now. On to other issues...
_________________
Eric
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