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 support@ccsinfo.com

help about 16f676

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







help about 16f676
PostPosted: Tue Aug 31, 2004 11:17 am     Reply with quote

hi,
I make a project with 16f676.
Code:

#include <16F676.h>
#device adc=10
#use delay(clock=4000000)
#fuses INTRC_IO,NOWDT


#define In0    PIN_C1
#define In1    PIN_C2
#define In2    PIN_C0
#define In3    PIN_C3
#define In4    PIN_C4
#define In5    PIN_C5

#define Out0   PIN_A4
#define Out1   PIN_A2
#define Out2   PIN_A5
#define Out3   PIN_A1

#define An0    PIN_A0

unsigned long lettan=0;




void main() {
   setup_adc_ports(sAN0|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_4);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   set_adc_channel(0);
   delay_ms(10);


   while(1) {

      lettan = READ_adc();

      output_bit(Out3,1);
      output_bit(Out2,1);

   }

}


If I set Out3(Pin RA1) only the output pin is HIGHT, but if I set Out2 and Out3 or another output the Out3(Pin RA1) blink.
Why ????

could alyone help me ???

Regards Mirrko
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 31, 2004 12:51 pm     Reply with quote

1. Post your version of the compiler.

2. What do you have connected to each of your "Out" pins ?
Describe the circuit (list all components).

3. What is the purpose of your test program ? It doesn't appear
to do anything useful. The while() loop doesn't have a delay_ms()
statement, so it runs at full speed. The "Out" pins are always set
to 1, so they will never change. The read_adc() value is not
displayed. So what's the purpose ?
mirberti
Guest







help about 16f676
PostPosted: Fri Sep 03, 2004 9:13 am     Reply with quote

My compiler version is : 3.148

The output pin is connected with ULN2003 and after an relay.
When I set the output the pin blink in high freqency and I dont understand why.

I supposed is the setup of PIC but I don't understad who is it.

I used PIC16F676 with internal 4 MHZ oscillator.

regards

Mirko
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Tue Sep 07, 2004 2:05 pm     Reply with quote

I think verifying the connections to your pins is in order (if you have not found your problem yet).

It sounds like your device may be reseting. How do you have MCLR connected (can you use the NOMCLR option)?

Are you trying to source too much current (that would reset your device as well)?
Trampas



Joined: 04 Sep 2004
Posts: 89
Location: NC

View user's profile Send private message MSN Messenger

PostPosted: Tue Sep 07, 2004 2:39 pm     Reply with quote

mirberti,

In MPLAB select View->Dissassembly. This will display the C code and the assembly instructions the C code produced. Then cut an paste that code here. Looking at the disassembly it will be easy to see if the code is correct. Then if the code is correct you know your problem is most likely a hardware problem like the watch dog enabled, or the brown out detection.

Trampas
maria
Guest







help with 16F676
PostPosted: Fri Dec 03, 2004 10:08 am     Reply with quote

Hi

I have had exactly the same problem with the PIC12F675(CCS PCM v 3.099).

I sorted out as soon as I got rid of the built-in function for disabling the comparator, i.e

setup_comparator(NC_NC_NC_NC);

and replaced by

#byte CMCON=0X19

and inside 'main'


CMCON=0x07; //Disable the comparator


and the output stopped blinking.

I checked the memory map for the PIC16F676 and this register is at the same position.

I hope this helps Razz
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