
Warning conflicting types for...
Publicado por Jose (3 intervenciones) el 14/01/2015 19:47:25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <stdint.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <math.h>
#define OFFSET 1.65
uint16_t valorTabla[192];
uint16_t valorRMS = 0;
void adc_init()
{
ADMUX |= (1<<REFS0);
ADCSRA |= (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
ADCSRA |= (1<<ADPS2) | (1<<ADPS1); // XTAL/64 = 125 kHz
ADCSRA |= (1<<ADSC); // Start conversion
sei();
}
ISR (ADC_vect){
static uint8_t index = 0; // variable index, recorre la tabla asignando valores.
valorTabla[index]=ADC;// Da valor a la tabla de asignacion de valores.
index++;
if (index == 192){
index = 0;
calcularRMS();
encenderLed();
}
}
int main(void)
{
adc_init();
DDRC=0xff;//Puerto C como salida
DDRD=0xff;//Puerto D como salida
while(1)
{
}
}
void encenderLed (){
if (valorRMS<=0.3)
{
PORTD=0b00000000;
}
if (valorRMS<=0.6)
{
PORTD=0b00000001;
}
if (valorRMS<=0.9)
{
PORTD=0b00000011;
}
if (valorRMS<=1.2)
{
PORTD=0b00000111;
}
if (valorRMS<=1.5)
{
PORTD=0b00001111;
}
if (valorRMS<=1.8)
{
PORTD=0b00011111;
}
if (valorRMS<=2.1)
{
PORTD=0b00111111;
}
if (valorRMS<=2.4)
{
PORTD=0b01111111;
}
if (valorRMS<=2.7)
{
PORTD=0b11111111;
}
if (valorRMS<=3)
{
PORTD=0b11111111; PORTC=0b00000001;
}
if (valorRMS<=3.3)
{
PORTD=0b11111111; PORTC=0b00000011;
}
}
void calcularRMS (){
valorRMS = 0;
uint16_t valorCuadrado = 0;
uint16_t i = 0;
for (i=0; i<191; i++){
valorCuadrado = pow( valorTabla[i], 2);
valorRMS = valorRMS + valorCuadrado;
}
valorRMS = sqrt((valorRMS / 192) - OFFSET);
}
Para mi punto de vista debería ser un programa sencillo, entra una tensión al adc ya adecuada para no superar los 3,3 y evitar valores negativos... Se calcula el RMS de esa tension y encendemos LED´s segun este valor.
Al compilar no surgen errores, solo los siguientes wanings:
Warning 5 conflicting types for 'calcularRMS' [enabled by default] C:\GccApplication2\GccApplication2\GccApplication2.c 99 6 GccApplication2
Warning 3 conflicting types for 'encenderLed' [enabled by default] C:\GccApplication2\GccApplication2\GccApplication2.c 51 6 GccApplication2
Warning 1 implicit declaration of function 'calcularRMS' [-Wimplicit-function-declaration] C:\GccApplication2\GccApplication2\GccApplication2.c 34 3 GccApplication2
Warning 2 implicit declaration of function 'encenderLed' [-Wimplicit-function-declaration] C:\GccApplication2\GccApplication2\GccApplication2.c 35 3 GccApplication2
Message 6 previous implicit declaration of 'calcularRMS' was here C:\GccApplication2\GccApplication2\GccApplication2.c 34 3 GccApplication2
Message 4 previous implicit declaration of 'encenderLed' was here C:\GccApplication2\GccApplication2\GccApplication2.c 35 3 GccApplication2
En fin, os escribo por desesperación ya no se que mas hacer, y lo debo de entregar mañana.
Un abrazo, y si esto sale adelante... estáis invitados a unas cañas xD
Valora esta pregunta


0