Eu estou usando esse código do Designer, mas ele apresenta um erro na leitura.
Ele está mostrando 822 para a tensão de 2,5 volts.
Onde estará o meu erro?
Desde já agradeço a ajuda.
- Código: Selecionar todos
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <stdlib.h>
#define RESOLUTION 12 // ADC resolution
#define SCALE_BG (( 1 << RESOLUTION)/55) // BarGraph scale factor
float iResult;
void Tempo(void) // rotina para gastar tempo
{
BYTE Tempo1, Tempo2;
for(Tempo1 = 0; Tempo1 <= 254; Tempo1++)
{
for(Tempo2 = 0; Tempo2 <= 254; Tempo2++)
{
}
}
} // fim da rotina gasta tempo // ADC result variable
void main()
{
BYTE bgPos; // BarGraph position
UART_1_Start(UART_PARITY_NONE); // Enable UART
UART_1_CPutString("Example ADC_UART_LCD"); // Example string
UART_1_PutCRLF();
PGA_1_Start(PGA_1_MEDPOWER); // Turn on PGA power
ADCINC12_1_Start(ADCINC12_1_MEDPOWER); // Turn on ADC power
ADCINC12_1_GetSamples(0); // Sample forever
M8C_EnableGInt; // Enable Global interrupts
while (1)// Main loop
{
if (ADCINC12_1_fIsDataAvailable() != 0) // If ADC sample is ready...
{
iResult = ADCINC12_1_iGetData() + 2048; // Get result, convert to unsigned and clear flag
ADCINC12_1_ClearFlag();
UART_1_PutSHexInt(iResult); // Print result to UART
UART_1_PutCRLF(); // Tack on a CR and LF
Tempo();
}
}
}