pic16f690

BobTPH

Joined Jun 5, 2013
3,689
1. Show us the entire circuit. What you described might not run for multiple reasons if those are the only coonections.

2. What are the configuration settings? Most notably the oscillator selection.

Bob
 

jpanhalt

Joined Jan 18, 2008
11,088
1) What is the program supposed to do? Did you write it or get if off the internet?
2) Can you show the code? If you only loaded a hex file, even posting that might help.
 

Thread Starter

huida__huida

Joined Apr 18, 2014
7
Code:
unsigned int x;
unsigned int y;
float adjpot;
float pospot;

void main() {
//ANSEL=0X4;
TRISA=0XFF;
//ANSELH=0;
TRISB=0;
do{
x= adc_read(0);
adjpot=5.0*x/1023;
y=adc_read(1);
pospot=5.0*y/1023;
if(pospot>adjpot){
portb.f4=1;
portb.f5=0;
portb.f6=1;
portb.f7=0;
}
if(pospot< adjpot){
portb.f4=0;
portb.f5=1;
portb.f6=0;
portb.f7=1;
}
if(pospot==adjpot){
portb=0;
}
}while(1);
}
 
Last edited by a moderator:

jpanhalt

Joined Jan 18, 2008
11,088
Oscillator selection has nothing to do with the code you posted, except if you use an external crystal, that will be on PortA and will require RA4 to be an output. Presumably, you are also using PortA for analogue input/ADC. You have not initialized PortC. It is set as an analogue input on all pins.

For the oscillator, which do you plan to use:

1605870504390.png

An internal oscillator (i.e., choices 7 or 8) is often easier to use, and I would recommend selection 8 unless you need the oscillator output for something else.
 
Top