Commit 17d365e7 by karudu

Väiksed parandused

parent 837bf1e0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE *File = fopen("adc_vtable.ino", "w");
printf("Enter max voltage\n");
double Max;
scanf("%lf", &Max);
fprintf(File, "const char FLASH_VoltageTable[1024 * 3] PROGMEM =\n");
fprintf(File, "{\n");
for(int i = 0; i < 1024; i++)
{
char Buf[16];
sprintf(Buf, "%.02f", ((double)i / 1023.0) * Max);
fprintf(File, "\t'%c', '%c', '%c',\n", Buf[0], Buf[2], Buf[3]);
}
fprintf(File, "};\n");
return 0;
}
\ No newline at end of file
...@@ -65,7 +65,7 @@ void Error() ...@@ -65,7 +65,7 @@ void Error()
void InitADC() void InitADC()
{ {
ADCSRA = bit(ADEN) | bit(ADIE) | bit(ADIF); // Enable the ADC and the read complete interrupt ADCSRA = bit(ADEN) | bit(ADIE) | bit(ADIF); // Enable the ADC and the read complete interrupt
ADCSRA |= bit(ADPS2); // Prescaler 16 ADCSRA |= bit(ADPS2) | bit(ADPS1); // Prescaler 64
ADMUX = bit(REFS0) | PIN_ADC; ADMUX = bit(REFS0) | PIN_ADC;
ADCSRB = bit(ADTS0) | bit(ADTS2); // Timer 1 CompareB ADCSRB = bit(ADTS0) | bit(ADTS2); // Timer 1 CompareB
ADCSRA |= bit(ADATE); // Enable auto trigger ADCSRA |= bit(ADATE); // Enable auto trigger
...@@ -124,9 +124,13 @@ void SetTimerPeriod(int Period) ...@@ -124,9 +124,13 @@ void SetTimerPeriod(int Period)
sei(); sei();
} }
unsigned long AdcT = 0;
// ADC complete ISR // ADC complete ISR
ISR(ADC_vect) ISR(ADC_vect)
{ {
/*Serial.println(micros() - AdcT);
AdcT = micros();*/
//unsigned long tstart = micros(); //unsigned long tstart = micros();
//Serial.println((ADC / 1023.0) * 4.8); //Serial.println((ADC / 1023.0) * 4.8);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment