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

Code loads but part does not run?? PIC16LF819

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







Code loads but part does not run?? PIC16LF819
PostPosted: Wed Nov 01, 2006 10:13 am     Reply with quote

I have complied a new program for a PIC16LF819 part. I have compiled my code (PCW 3.249) and loaded it on my board using a ICD-U40. The code seems to load and i can verify it, but when i try look at my circuit, it does notthing. I have backed it way down to just turning one output high and it is not high, it is low. I beleave the ICD works, although it do question it because of problems i have had with previous projects, so i have a new one coming just in case. I have not used the LF parts a lot and i am running this one with a IntRC. From the parts spec sheets i looks like i should be able to do this. Does any one have comments.

#include <16F819.h>
#device adc=10
#use delay(clock=4000000)
#fuses WDT,INTRC, PUT, NOMCLR, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT
#include <math.h>

#use fast_io(A)
#define htr_th PIN_A0 //heater thermistor
#define cell_th PIN_A1 //cell pack thermistor sense
#define isns PIN_A2 //current sense
#define vbat PIN_A3 //battery voltage sense

#use fast_io(B)
#define SMBD PIN_B1 //data line
#define ch_en PIN_B2 //turn on/off for charger
#define SMBC PIN_B4 //clock line
#define htr_en PIN_B5 //turn on/off for heater

//#define INTS_PER_SECOND 76
#define INTS_PER_SECOND 15

//#byte port_b=6
//#byte INTCON=0x0B

////////////////////////////////////////////////////////////////////////////////

char host_prn,no_chg,i,t_valid,loop=1,wr_n;
long htr_temp,pack_temp,max_time,tconst,seconds,int_count,current,v_bat;

////////////////////////////////////////////////////////////////////////////////

/*#int_rtcc
clock_isr()
{
if(--int_count==0) //decrement counter until 0
{
++seconds; //count up seconds
int_count=INTS_PER_SECOND; //reset counter
if (seconds>=65000)
seconds=65000;
}
}*/






void main()
{

output_low(ch_en); //charger enabled
output_high(htr_en); //heater off
output_float(SMBC); //release data line
output_float(SMBD); //release clock line
setup_oscillator(osc_4mhz);
setup_adc_ports(All_ANALOG);
setup_adc(ADC_CLOCK_DIV_8);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_256);
set_rtcc(0);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
port_b_pullups(false); //added to see if this could be used on chg

set_tris_a(0b00001111);
set_tris_b(0b00000000);

output_low(ch_en); //charger enabled
output_high(htr_en); //heater off
output_float(SMBC); //release data line
output_float(SMBD); //release clock line

loop=1; //initialize all vairables
int_count=INTS_PER_SECOND; //used for timer
seconds=0; //clear out variable
max_time=900; //counter for time, 8 hours
for (i=0;i<=100;i++) //half second delay
{
delay_ms(10); //delay of 1 sec
restart_wdt();
}


while (TRUE)
{

/*set_adc_channel(1); //read pack thermistor voltage
delay_us(500);
restart_wdt();
pack_temp=read_adc();*/
seconds=0;
output_high(htr_en);
for (i=0;i<=100;i++) //half second delay
{
delay_ms(10); //delay of 1 sec
restart_wdt();
}
output_low(htr_en);
for (i=0;i<=100;i++) //half second delay
{
delay_ms(10); //delay of 1 sec
restart_wdt();
}

/*while(pack_temp<=512) //temp less than 25C
{
while(seconds<=max_time) //one minute timer
{
set_adc_channel(0); //read heater thermistor from host
delay_us(500);
restart_wdt();
htr_temp=read_adc();
if (htr_temp<605>=559) //heater temperature is greater than 30C
{
output_low(htr_en); //turn heater off until it cools 5C
set_adc_channel(0); //read heater thermistor from host
delay_us(500);
restart_wdt();
htr_temp=read_adc();
set_adc_channel(1); //read pack thermistor voltage
delay_us(500);
restart_wdt();
pack_temp=read_adc();
}
}
}
output_low(htr_en);
set_adc_channel(1); //read pack thermistor voltage
delay_us(500);
restart_wdt();
pack_temp=read_adc();
while (seconds<=1800)
{
output_low(htr_en);
set_adc_channel(1); //read pack thermistor voltage
delay_us(500);
restart_wdt();
pack_temp=read_adc();
}
output_low(htr_en);
set_adc_channel(1); //read pack thermistor voltage
delay_us(500);
restart_wdt();
pack_temp=read_adc();
seconds=0;
}*/
}
}
Ttelmah
Guest







PostPosted: Wed Nov 01, 2006 10:28 am     Reply with quote

First comment. When posting code, use the code button, and turn off html (disable HTML in this post). Without this, the result is basically unreadable, making diagnosis almost impossible.
Second comment, remove the remmed out code, we don't want to have to wade hrough lots of code that is doing nothing.
However with that said, there is one glaring problem. You are enabling interrupts, but have 'remmed' out the interrupt handler. This will result in the chip almost certainly hanging completely, and might well explain what you are seeing.

Best Wishes
nrmeyer34
Guest







PostPosted: Wed Nov 01, 2006 10:52 am     Reply with quote

Thanks for the comments. It did not matter if the interrupt was in there or not, it performs the same way.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 01, 2006 11:36 am     Reply with quote

You're using an LF part, which implies you're running it at a voltage
below 5v. Are you running at 3.3v ? In that case, you can't enable
the BROWNOUT fuse, or the device will remain reset. You have to
use NOBROWNOUT.

From the 16F819 data sheet (emphasis added):
Quote:

12.7 Brown-out Reset (BOR)
The configuration bit, BOREN, can enable or disable
the Brown-out Reset circuit. If VDD falls below VBOR
(parameter #D005, about 4V) for longer than TBOR
(parameter #35, about 100 µs), the brown-out situation
will reset the device. If VDD falls below VBOR for less
than TBOR, a Reset may not occur.
Once the brown-out occurs, the device will remain in
Brown-out Reset until VDD rises above VBOR.



Some PICs have the ability to set the Brownout voltage to
a lower level so they can work with a 3.3v Vdd, but not this PIC.
It has a fixed Brownout voltage of about 4.0v.
Guest








PostPosted: Thu Nov 16, 2006 3:43 pm     Reply with quote

I made this change along with a few others and i am running fine now. Thanks
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