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

18f4680 not starting up

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



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

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

18f4680 not starting up
PostPosted: Sun Sep 21, 2008 6:42 pm     Reply with quote

Hi. I seem to be running into a dead end. Its the first time I am using an 18f pic and for some unknown reason the pic just does not want to run at all. I tried this program on 2 completely separate boards and the LED on pin B5 does not even go on. I even removed the read analog statement and changed oscillator fuses and delay clock statements but the pic still does not want to start up. If I do a memory check on the pic all is okay and I have got a 1uf cap from MCLR to ground. I also tested and the pic does get 5 volt on both Vdd pins and both Vss pins are grounded. Am I doing something wrong in the program or what else needs to be done differently from the 16f pics? Any help or advice would be greatly appreciated as I ran out of faults to look for.

Code:
#include <18f4680.h>
#device adc=8
#fuses RC_IO,NOWDT,NOPROTECT,PUT
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
   

main()
{
    void setup();
    void read_analog();

while(1)
{
 read_analog();
 output_high(pin_b5);
 delay_ms(500);
 output_low(pin_b5);
 delay_ms(500);
}

}

void setup()
 {   
     //setup_oscillator(OSC_8MHZ|OSC_INTRC|OSC_PLL_ON);
     setup_adc_ports(AN0_TO_AN1);
     setup_adc( ADC_CLOCK_DIV_64  );
  }

void read_analog()
{
  int ch0,ch1;
 
  set_adc_channel(0);
  delay_us(2);
  ch0=read_adc();
  putc(ch0);
 
  set_adc_channel(1);
  delay_us(2);
  ch1=read_adc();
  putc(ch1);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 21, 2008 7:19 pm     Reply with quote

Quote:
For some unknown reason the pic just does not want to run at all.

#include <18f4680.h>
#device adc=8
#fuses RC_IO,NOWDT,NOPROTECT,PUT

Look at the list of fuses in this post. Read the description of your
oscillator fuse and read the description of the one that you should be using:
http://www.ccsinfo.com/forum/viewtopic.php?t=31698
Ttelmah
Guest







PostPosted: Mon Sep 22, 2008 2:16 am     Reply with quote

Your serial won't work. You are telling the chip at the start you are using a 4Mhz clock, but then change the clock to 8MHz, using the oscillator setup...
The serial rates are set by the clock statement, which will then be wrong...

Unfortunately (on the fuses), CCS are being a little 'annoying', in their nomenclature. On some newer chips, which don't support external RC oscillators, they use 'RC', as nomenclature for the internal oscillator, while on most chips (your's included), you have to use 'INT_RC' for this....

Best Wishes
Gerhard



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

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

PostPosted: Mon Sep 22, 2008 2:34 am     Reply with quote

Thanks. I got it working using the INTRC fuse rather than the RC fuse. I do however seem to be a having a problem enabling the PLL on the chip. I have started this discussion in another post. I tried seting up the PLL exactly as stated with this
Code:
#fuses INTRC_IO,NOWDT,NOPROTECT,PUT
#use delay(clock=32M)

However the LED still only blinks once every 4s which indicates to me that although I stated in the clock statement that the chip runs at 32M it is actually still running at 8M. I also tried setting the bit as follows.

Code:
#byte OSCTUNE=0xF9B
#define PLLEN 6
.........
bit_set(OSCTUNE,PLLEN);

And it is still only blinking every 4s. I also tried it with the normal software code like this
Code:
#use delay(clock=32M, oscillator=8M)

Then the PIC does not run at all.

I tried the following as well
Code:
setup_oscillator(OSC_32MHZ|OSC_PLL_ON);


This also makes the LED only blink every 4s. All the time I am keeping the #use_delay(clock=32M) as to let the compiler know what my clock speed is.

Could there be a problem with the PIC or the compiler?
I am using MPLAB7.62 with CCS 4.033.
Ttelmah
Guest







PostPosted: Mon Sep 22, 2008 3:01 am     Reply with quote

It could easily be the compiler. 4.033, is very 'early' in the 'near workable' V4 versions.
Make a really simple test:
Code:

#include <18f4680.h>
#device adc=8
#fuses INTRC_IO,NOWDT,NOPROTECT,PUT,NOXINST
#use delay(clock=32M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
   
VOID main(VOID) {
    //Try with and without this
    setup_oscillator(OSC_32MHZ|OSC_INTRC);
    while(true) {
        output_high(pin_b5);
        delay_ms(500);
        output_low(pin_b5);
        delay_ms(500);
    }
}

Forget about everything else. Does this give 1Hz, or 0.25Hz?.
If it gives 0.25Hz, ask for a fix from CCS (hopefully they will allow you a later version).

Best Wishes
Gerhard



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

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

PostPosted: Mon Sep 22, 2008 6:57 am     Reply with quote

Thanks. I did it exactly the way you showed but i still get a 0.25Hz blink with and without the oscillator setup line so i guess the compiler is not set up to activate the PLL.
I will see about another compiler. Is there a more bit addressable way to do this that would enable the compiler to overcome this problem? I tried as stated earlier but that also doesn't work.

Thanks for the help.
Ttelmah
Guest







PostPosted: Mon Sep 22, 2008 7:31 am     Reply with quote

The method posted earlier, certainly should work:
Code:

#byte OSCTUNE=0xF9B
#bit PLLEN=OSCTUNE.6

#define PLLON PLLEN=1
#define PLLOFF PLLEN=0

//Then

PLLON;

//should enable the PLL

However, this will _only_ work, if you are in INTRC mode. In your previous post, you seemed to by trying to use HS mode. HS mode, requires an external crystal, and to use the PLL, it has to be turned on in the fuses with HSPLL. For all modes except INTRC, and INTRC_IO, this bit will always read as zero.

Best Wishes
Gerhard



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

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

PostPosted: Mon Sep 22, 2008 8:01 am     Reply with quote

Thanks for the help.
I think I am at a dead end now and should look at another compiler version. I have done all that was discussed but still this does not want to work.
This is the program that I am running so any other options would be appreciated.
Code:
#include <18f4680.h>
#device adc=8
#fuses INTRC,NOWDT,NOPROTECT,PUT,NOXINST
#use delay(clock=32M)

#byte OSCTUNE=0xF9B
#bit PLLEN=OSCTUNE.6

#define PLLON PLLEN=1
#define PLLOFF PLLEN=0

 
VOID main(VOID) {
     PLLON;
    //Try with and without this
   // setup_oscillator(OSC_32MHZ|OSC_INTRC);
    while(true) {
        output_high(pin_c6);
        delay_ms(500);
        output_low(pin_c6);
        delay_ms(500);
        }
}


Last edited by Gerhard on Mon Sep 22, 2008 8:54 am; edited 1 time in total
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Sep 22, 2008 8:17 am     Reply with quote

Quote:
Is there a more bit addressable way to do this that would enable the compiler to overcome this problem? I tried as stated earlier but that also doesn't work.


Yes, surely. If it would be the case that the present CCS C version handles some built-in functions incorrect (I don't know regarding your chip, but it does happen), than you can still set any PIC register directly. If you consider some of the so-called professional PIC compilers, your most likely stuck to direct register programming anyway, you can get this more simple with CCS.
Ttelmah
Guest







PostPosted: Mon Sep 22, 2008 9:24 am     Reply with quote

I'd say moan at CCS for a later version.
I have just put basically the same code, into 4.027 (the only one I have around this time), and it doesn't work. In 4.042 (next version I have installed), it happily runs...

Best Wishes
Gerhard



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

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

PostPosted: Mon Sep 22, 2008 1:12 pm     Reply with quote

Thanks Ttelmah for all the help. I'll do that.
Appreciated.
Viraj
Guest







18f4620
PostPosted: Mon Sep 22, 2008 7:02 pm     Reply with quote

I am just a beginner and not much comfortable with the PIC programming. So is there anyone who could help me modifying the code given below to work on CCS PCW compiler for PIC18F4620.
Viraj
Guest







18F4620
PostPosted: Mon Sep 22, 2008 7:06 pm     Reply with quote

I am sorry, the code is as follows:
Code:

/**********************************************************
 *
 *         HTTP Implementation for Microchip TCP/IP Stack
 *
 **********************************************************



Microchip Proprietary code deleted.
-- CCS Forum Moderator
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Sep 22, 2008 7:24 pm     Reply with quote

Viraj,
Some things to consider:
1. You are posting Microchip proprietary code on a CCS website which
may make Microchip unhappy!
2. There is no reason to modify the Microchip code since CCS already
has a ported version on their Download page.
3. You tacked this on the back end of someone else's topic. You should
have started a new thread.
4. Your being a beginner, this is not a good time to be messing with
something like modifying a large chunk of complicated code (TCP/IP
stack) that does not come as part of a kit. TCP/IP is many times difficult
to work with for experienced PIC programmers.

If you are using the CCS compiler I suggest that you get an Ethernet kit
from somewhere and use the CCS TCP/IP stack. FWIW, I don't believe
the demo compiler will support the TCP/IP stack since it is so big.

A word of advice, search this forum for the word "TCP" before asking
questions. MANY people have talked about this in the past and most of
your questions will likely be answered. If you had done that before you
would have found out what I just told you about the CCS version stack
and the conversion issues for the Microchip version.

Good Luck
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