View previous topic :: View next topic |
Author |
Message |
mirberti Guest
|
help about 16f676 |
Posted: Tue Aug 31, 2004 11:17 am |
|
|
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
|
|
Posted: Tue Aug 31, 2004 12:51 pm |
|
|
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 |
Posted: Fri Sep 03, 2004 9:13 am |
|
|
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
|
|
Posted: Tue Sep 07, 2004 2:05 pm |
|
|
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
|
|
Posted: Tue Sep 07, 2004 2:39 pm |
|
|
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 |
Posted: Fri Dec 03, 2004 10:08 am |
|
|
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 |
|
|
|