|
|
View previous topic :: View next topic |
Author |
Message |
adrianrb Guest
|
16F628 adc error |
Posted: Tue Jan 09, 2007 5:56 am |
|
|
Hi all!
I�m trying to use the ADC ports from a PIC16F628, just like I can
do in 16F88, but I�m getting erros. Could someone help me?
Code (works fine in 16F88):
<pre>
#include <16F628A> // Define processador
#include "..\mudancas.h" // minha personalizacao
#fuses XT, NOWDT, NOPROTECT, NOPUT, NOLVP, NOBROWNOUT//, NOCPD, NOFCMEN, NOIESO, NOMCLR
#use delay(clock=4000000) // Informa o clock para rotinas de tempo.
#use FAST_IO(A) // portA sob meu controle
#use FAST_IO(B) // portB sob meu controle
#byte porta = 5 // endereco do port a
#byte portb = 6 // portb no endereco do port b
#bit ENB = portb.4 // sinal ENABLE
#bit RS = portb.5 // sinal RS
#define delay 500
////////////////////////////////////////////////////////////////////////////
// Prototipos obrigatorios com ";" no final.
void Inicializa(void); // nao recebem e nem devolve, valores
void Limpa(void);
void Mensagem(void);
void Linha1(char coluna); // recebem um char, ja indicando o nome
void Linha2(char coluna);
///////////////////////////////////////////////////////////////////////////
// Declaracao de variaveis em RAM
char i, posicao;
char MensRam [32]; // devo copiar da ROM para a RAM porque
// no pic nao posso fazer ponteiros para
// a memoria ROM.
//byte const Mensg_1 [33] = { "Ola Mundo!" };
char d[4] = {'0', '0', '0', '0'};
char num;
// Fun��es auxiliares
#include "..\util.c"
// Programa principal
void main()
{
TRISB(0); // PortB: Saida dados LCD
RS = 0;
ENB = 0;
Inicializa(); // inicializa o portb
for(;;)
{
// Leitura da porta anal�gica
TrisA(1);
setup_adc_ports(0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(PIN_A0);
num = read_adc();
setup_adc(ADC_OFF);
// Converte o valor num vetor
num2vet(num);
TrisA(0);
// Escreve o valor no LCD
for (i = 0; i < 4; i++)
MensRam[i] = d[i];
Mensagem(); // escrevo a mensagem
Delay_Ms(delay); // espero 1 seg
Limpa(); // limpo o portb
Delay_Ms(delay);
}
}
</pre>
Errors:
Executing: "C:\CCSC\Ccsc.exe" "lcd_rom.c" +FM +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 12 "C:\Daysoft\Projetos\Pic\Testes\C\LCD1\lcd_rom.c" Line 58(9,24): Undefined identifier setup_adc_ports
*** Error 12 "C:\Daysoft\Projetos\Pic\Testes\C\LCD1\lcd_rom.c" Line 59(9,18): Undefined identifier setup_adc
*** Error 12 "C:\Daysoft\Projetos\Pic\Testes\C\LCD1\lcd_rom.c" Line 60(9,24): Undefined identifier set_adc_channel
*** Error 12 "C:\Daysoft\Projetos\Pic\Testes\C\LCD1\lcd_rom.c" Line 62(11,19): Undefined identifier read_adc
*** Error 12 "C:\Daysoft\Projetos\Pic\Testes\C\LCD1\lcd_rom.c" Line 64(9,18): Undefined identifier setup_adc
5 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Tue Jan 09 09:52:59 2007
Why compiler doesn�t find the functions *adc*?
Tks in advance,
Adrian |
|
|
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
Re: 16F628 adc error |
Posted: Tue Jan 09, 2007 6:47 am |
|
|
adrianrb wrote: | Hi all!
I�m trying to use the ADC ports from a PIC16F628, just like I can
do in 16F88, but I�m getting erros. Could someone help me?
|
Well your first clue should be this
Quote: |
Undefined identifier setup_adc_ports
Undefined identifier setup_adc
Undefined identifier set_adc_channel
Undefined identifier read_adc
Undefined identifier setup_adc
|
Have a look at the CCs header files.
The 16F88 will have this line somewhere in 16F88.h header file
////////////////////////////////////////////////////////////////// ADC
Do you recognise the functions underneath?
Now try and find this line in the 16F628.h header file.
Hint it isn't there - the 16F628 doesn't have an ADC hence the errors. |
|
|
adrianrb Guest
|
ok, but I�m get confused... |
Posted: Tue Jan 09, 2007 7:11 am |
|
|
Adrian too??? Nice... 8-)
I get confused �cause 16F628 datasheet shows port AN0, AN1...,
but no ADC at all...
Tks for your reply...
I�ll search for another chip.
Adrian |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 09, 2007 7:56 am |
|
|
The CCP module (which the 628 does have), also uses analog input pins...
Best Wishes |
|
|
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
Re: ok, but I�m get confused... |
Posted: Wed Jan 10, 2007 6:10 am |
|
|
adrianrb wrote: |
I get confused �cause 16F628 datasheet shows port AN0, AN1...,
but no ADC at all...
|
If you look at Table 2-1, you will see that they refer to the Comparator inputs |
|
|
|
|
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
|