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

Setting up the PIC

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



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

Setting up the PIC
PostPosted: Wed Dec 20, 2006 9:32 am     Reply with quote

I'm relatively new to the PIC scene, and the previous projects I have completed were during Uni courses.

Now that I'm attempting to do something outside of that, and I'm unable to get my PIC to initialise.

I think I've set everything up correctly, although I obviously haven't!

Code:
#include <16f914.h>
#fuses HS,NOWDT,NOPROTECT, PUT, INTRC_IO
#use delay(clock=8000000)
#define led_0 pin_a4
#define led_1 pin_d4
#define led_2 pin_d5
#define led_3 pin_d6
#define led_4 pin_d7
#use fixed_io(a_outputs=led_0)
#use fixed_io(d_outputs=led_1,led_2,led_3,led_4)

void main()
{
   output_high(led_0);
   output_high(led_1);
   output_high(led_2);
   output_high(led_3);
   output_high(led_4);
}


That's it. I'm trying to get the PIC to atleast respond and give me an output. The outputs have LED/resistor networks attached to them so setting the outputs high should turn the LED's on.

However I'm getting nothing. The PIC is programming, a 16F914, since the CSUM varies accordingly with each change in code, yet the outputs remain resolutely dead. Even switching for a 2nd PIC doesn't change.

If anyone can point out my mistake, or where I can look for assistance on this, I will be eternally grateful.
Ttelmah
Guest







PostPosted: Wed Dec 20, 2006 9:46 am     Reply with quote

'HS', and 'INTRC_IO', are mutually exclusive. You can only have _one_ oscillator configuration. 'HS', means 'use an external crystal, greater than 4MHz', and 'INTRC_IO', means 'use the internal oscillator'...

Best Wishes
aodj



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

PostPosted: Wed Dec 20, 2006 9:50 am     Reply with quote

Thanks for the reply, I've just deleted that part, and I'm still getting nothing from the chip at all.
Ttelmah
Guest







PostPosted: Wed Dec 20, 2006 10:08 am     Reply with quote

OK. Now add the following:
Code:

   //At the start of your main
   //Otherwise the PORTA pins, and some PORTE ones
   //will wake up as analog inputs
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);

   //At the end of the main
   while (TRUE) ;
   //Otherwise the code will drop 'off the end', and send the
   //processor to sleep - shouldn't stop the pins being activated,
   //but is important if you want to actually do anything

Also, have you got the MCLR pin pulled to +5v. If not, add the fuse 'NOMCLR', otherwise the processor will never start.

Best Wishes
aodj



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

PostPosted: Wed Dec 20, 2006 10:16 am     Reply with quote

I'll buy you a big internet beer, that solved it! It was the NOMCLR that fixed it.
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