Página 1 de 1

[RESOLVIDO] Erro na função SetTmrCCPSrc

MensagemEnviado: 10 Out 2011 14:35
por ÁgioFelipe
Alguém poderia me ajudar nesse erro muito estranho:
Error - could not find definition of symbol 'SetTmrCCPSrc' in file './PIC18F4550.o'.

Meu código:
Código: Selecionar todos
#include <p18F4550.h>
#include <delays.h>
#include <adc.h>
#include <stdlib.h>
#include <timers.h>
#include <compare.h>


#pragma config FOSC = HS
#pragma config PBADEN = OFF
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config MCLRE = OFF
#pragma config PWRT = ON
#pragma config BOR = OFF


void main()
{                        
   SetTmrCCPSrc(T3_SOURCE_CCP);
   OpenCompare1(COM_INT_ON & COM_TRIG_SEVNT, 60000);   

}


Agradeço a ajuda.

Re: Erro na função SetTmrCCPSrc

MensagemEnviado: 10 Out 2011 20:34
por andre_luis
Fazendo uma rápida busca na Web, notei que trata-se de uma macro :

Código: Selecionar todos
'---------------------------------------------------------------------------------
' Macro Name    : SetTmrCCPSrc
' Return Value  : None
' Parameters    : pConfig: bit definitions to configure Timer as a clock source to CCP module
' Description   : This routine configures the timer to work as a clock source to CCP module.
'               : Required timer has to be enabled by calling respective function.
' Notes         : The bit definitions for config can be found in the TimerDefs.inc file.

$define SetTmrCCPSrc(pConfig)         '
    T3CON  = T3CON & $B7              '
    WREG = pConfig & $48              '
    T3CON = T3CON | WREG              '

$endif


Está dentro da biblioteca Timers.inc que deve ser incluída no projeto :

http://www.logosfoundation.org/instrum_ ... Timers.inc


+++

MensagemEnviado: 10 Out 2011 21:17
por ÁgioFelipe
Acredito que não, pois tem um exemplo no livro do Alberto Noboru que utiliza essa função e não inclui timers.inc e sim timers.h.

MensagemEnviado: 11 Out 2011 10:34
por ÁgioFelipe
Problema resolvido.
Verificando a documentação do meu C18 (C:/MCC18/doc/periph-lib/Timer.htm) constatei a não existencia da função SetTmrCCPSrc, pelo menos na minha versão.
Para associar o Timer ao compare devo especificar na própria função OpenTimerX através do argumento T1_SOURCE_CCP, como por exemplo:

OpenTimer1(TIMER_INT_OFF & T1_8BIT_RW & T1_SOURCE_INT & T1_PS_1_1 & T1_SOURCE_CCP);

Até mais.[/code]