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

A question about 18f14k50

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



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

A question about 18f14k50
PostPosted: Sat Dec 04, 2010 1:28 am     Reply with quote

My compiler version is 4.108 and I want to write an easy blinking led program for testing. But I couldn't set its internal oscillator to 8MHZ.
My code:
Code:

#include <18F14K50.h>
#device adc=8
#include <PIC18F14K50_registers.h>
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                           //Also I have tried #FUSES XT and INTRC
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection         
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOMCLR                     //Master Clear pin enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES HFOFST               
#FUSES NOWRT0               
#FUSES NOWRT1               
#FUSES USBDIV2               
#FUSES BBSIZ2K                  //2K words Boot Block size               
#FUSES CPUDIV4                  //System Clock by 4
#FUSES PCLKEN               
#use delay(int=8000000)    //Also I have tried #use delay(clock=8000000)

#define LED PIN_A5

void main()
{
   OSCCON=01100111;
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
    //Example blinking LED program
    while(true){
      output_low(LED);
      delay_ms(1000);
      output_high(LED);
      delay_ms(1000);
    }

}

How can I blink a led with 18f14k50?
wireless



Joined: 02 Nov 2003
Posts: 16
Location: London England

View user's profile Send private message

PostPosted: Sat Dec 04, 2010 3:30 am     Reply with quote

Hi

I have not looked at your code in detail but you have set the OSCCON register to a huge decimal value.
OSCCON=01100111;

I think you intended it to be binary so you should have added a 'b' at the end of the number or expressed it a 0x67.
OSCCON=01100111b;

Regards

Terry
_________________
"An engineer is someone, who can do for 5 bob, what any dam fool can do for 10. " - Hon C S Royce Joint Founder of Rolls Royce.
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Sat Dec 04, 2010 5:47 am     Reply with quote

I changed my code as you said but the same problem is continuing.
OSCCON=0b01100111;
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Sat Dec 04, 2010 7:08 am     Reply with quote

And I can use it with external oscillator but I haven't used with internal oscillator, yet.
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Sat Dec 04, 2010 9:31 am     Reply with quote

Also I found a problem at 18f14k50's library. When I looked at its ASM list, I saw this line:
Code:

031A:  CLRF   FB4

This register (FB4) is unimplemented register which is only read. How can I avoid this problem? And also my oscillator problem is continuing.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 04, 2010 10:46 pm     Reply with quote

Try the following simple program:
Code:

#include <18F14K50.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP,NOPLLEN,CPUDIV1
#use delay(clock=4000000)

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

while(1)
  {
   output_high(PIN_A5);  // Blink an LED on Pin A5
   delay_ms(500);
   output_low(PIN_A5);
   delay_ms(500);
  }

}
 
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Mon Dec 06, 2010 12:33 am     Reply with quote

Is there any difference between "#use delay(clock=4000000)" and "#use delay(int=4000000)"?
Thanks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Dec 06, 2010 5:29 am     Reply with quote

Yes.
The first is the 'old' form. It _just_ says what frequency the chip is being clocked at.
On more modern compilers, the delay function will accept other parameters, making it partially replace the fuse functions. The second form you give, says 'use the internal oscillator at 4MHz', so automatically sets the INT_RC fuse if it is not already selected.

Best Wishes
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Mon Jan 24, 2011 3:45 am     Reply with quote

I couldn't work 18f14k50 with internal oscillator. I tried various compiler version (4.108, 4.110, 4.114). But I couldn't work with its internal oscillator. Is there anyone to try PIC18f14k50 with real hardware?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 24, 2011 12:45 pm     Reply with quote

I tested the program that I posted above on a 18F14K50 with vs. 4.114
and it worked. I tested it on a Microchip "Low pin count" 20-pin
development board and programmed it with a Pickit2. The Pickit2
provides +3.3v power to the 18F14K50. I jumpered pin A5 to the "DS1"
LED and it blinks at the correct rate.

If it doesn't work for you, then you likely have a hardware problem.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Mon Jan 24, 2011 3:39 pm     Reply with quote

I had an issue programming the 18F13K50 and a simple firmware update on my ICD fixed it right up. It might be worth consideration.
_________________
Vinnie Ryan
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