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

Weird behavior 16F819

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



Joined: 01 Jun 2012
Posts: 13

View user's profile Send private message

Weird behavior 16F819
PostPosted: Mon Apr 22, 2013 2:04 pm     Reply with quote

Im trying to get my 16F819 to work. For now just a simple led blink.

Problem: The led only blinks if i hold the MCLR (pin 4) with my fingers. If i let go of it, the led will just go into very random state (blinking, not blinking etc).

Here is the connection diagram:


Here it the code:
Code:
#include "c:\devices\16F819.h"
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES LVP                      //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOPROTECT                //Code not protected from reading

#use delay(clock=8000000)


void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
//   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);


   while(1){
output_high(PIN_A1);
delay_ms(350);
output_low(PIN_A1);
delay_ms(350);

}

}


Im using CCS v.4.010


Any help will be much appreciated
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Mon Apr 22, 2013 2:28 pm     Reply with quote

Get rid of LVP.

You do not want this, and it is causing the behaviour you are seeing.

As a general comment, it is bad practice to have pins left floating.

Best Wishes
Tunfiskur



Joined: 01 Jun 2012
Posts: 13

View user's profile Send private message

PostPosted: Mon Apr 22, 2013 2:34 pm     Reply with quote

Ttelmah wrote:
Get rid of LVP.

You do not want this, and it is causing the behaviour you are seeing.

As a general comment, it is bad practice to have pins left floating.

Best Wishes


Thanks,

Another question about floatings pins, I always have a problem with knowing what pins to connect to pullup resistors and who not to. Is there a rule of thumb or any details in the datasheet that i can use to determine that? Not only for 16f819 but more in general?

thanks
SuperDave



Joined: 22 May 2008
Posts: 63
Location: Madison, TN

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 22, 2013 2:59 pm     Reply with quote

Float is a potential problem on any pin designated as a digital INPUT (the most typical state at POR). Such pins have a very high impedance, meaning any leakage from anywhere can set their state and any varying leakage (AC line hum, local transmitter) will change their state. Even if you don't use those pins (and they are not interrupts!!) the constant state changing will draw more current.

Lots of fixes. Easiest is to Tris them as outputs. You could also tie them to power or ground but it would then be hard to hack and wack an additional input or output should the need arise. (General rule: do it in software instead of hardware if you have a choice.) If you are expecting production, pick a part with fewer pins and save some money as well.
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