Commit 5bb4cd1a authored by Martin Vítek's avatar Martin Vítek

Add some debug, fixes, disabled boost

parent 94c6d0e7
......@@ -5,6 +5,7 @@
#include <cstdint>
#include "ADC_class.h"
#include "NixieClock.h"
#include "GPIO.h"
/*
......@@ -73,7 +74,7 @@ class BoostConverter
//while (timer.STATUS.bit.SYNCBUSY) ;;
//Enable timer
timer.CTRLA.bit.ENABLE = 1;
//timer.CTRLA.bit.ENABLE = 1;
while (timer.STATUS.bit.SYNCBUSY) ;;
......@@ -85,7 +86,7 @@ class BoostConverter
*/
//48MHz, DIV1 -> 732Hz
TC3->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER_DIV4 | TC_CTRLA_PRESCSYNC_PRESC;
TC3->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER_DIV2 | TC_CTRLA_PRESCSYNC_PRESC;
TC3->COUNT16.INTENSET.reg = TC_INTENSET_ERR | TC_INTENSET_OVF;
TC3->COUNT16.CTRLA.bit.ENABLE = 1;
......@@ -145,6 +146,7 @@ class BoostConverter
(adc.value[adc.CURRENT_12V] > MAXIMUM_CURRENT_12V) */)
{
disable();
uart.send("Overvoltage: ");uart.send_dec(adc.value[adc.VOLTAGE_180V]);uart.send("\n\r\n\r");
}
}
......
......@@ -2,13 +2,15 @@
#include "USART.h"
//#include "ethernet_frame.h"
#include "ADC_class.h"
#include "NixieClock.h"
USART uart(SERCOM1->USART, 115200);
Debug debug(uart);
Debug::Debug(USART &uart) : uart(uart)
Debug::Debug(USART &uart): uart(uart)
{
}
......@@ -90,3 +92,31 @@ void Debug::frame(const ethernet_frame &frame)
uart.send_new_line();
}
*/
void Debug::adc()
{
/*
uart.send("Voltage 12V:\t");
uart.send_dec(adc.value[adc.VOLTAGE_12V]/1000);uart.send('.');uart.send_dec(adc.value[adc.VOLTAGE_12V%1000]);
uart.send_new_line();
uart.send("Voltage 180V:\t");
uart.send_dec(adc.value[adc.VOLTAGE_180V]/1000);uart.send('.');uart.send_dec(adc.value[adc.VOLTAGE_180V%1000]);
uart.send_new_line();
uart.send("Current 12V:\t");
uart.send_dec(adc.value[adc.CURRENT_12V]/1000);uart.send('.');uart.send_dec(adc.value[adc.CURRENT_12V%1000]);
uart.send_new_line();
uart.send("Current 180V:\t");
uart.send_dec(adc.value[adc.CURRENT_180V]/1000);uart.send('.');uart.send_dec(adc.value[adc.CURRENT_180V%1000]);
uart.send_new_line();
uart.send("Ambient light:\t");
uart.send_dec(adc.value[adc.AMBIENT_LIGHT]);
uart.send_new_line();
uart.send_new_line();
*/
}
......@@ -43,6 +43,7 @@ class Debug
void reg(const char* name, const uint8_t value);
void reg(const char* name, const uint16_t value);
//void frame(const ethernet_frame &frame);
void adc();
};
extern USART uart;
......
......@@ -135,7 +135,8 @@ class Input
public:
Input(volatile PortGroup& port, uint8_t bit): port(port),
bit(bit)
bit(bit),
inverted(false)
{
port.DIRCLR.reg = 1UL<<bit;
port.PINCFG[bit].reg |= PORT_PINCFG_INEN;
......
......@@ -13,7 +13,3 @@ NixieDisplay::NixieDisplay()
{
} //NixieDisplay
// default destructor
NixieDisplay::~NixieDisplay()
{
} //~NixieDisplay
......@@ -7,7 +7,7 @@
class NixieDisplay
{
private:
Output
public:
NixieDisplay();
......
......@@ -37,12 +37,16 @@ Output separator[2] = { Output(PORT->Group[0], PIN_PA24),
IRQ_test irq;
volatile bool dosomething;
void TC0_Handler()
{
if (TC0->COUNT16.INTFLAG.bit.OVF)
{
separator[0].toggle();
separator[1].toggle();
//separator[0].toggle();
//separator[1].toggle();
dosomething = true;
TC0->COUNT16.INTFLAG.reg = TC_INTFLAG_OVF;
}
......@@ -79,7 +83,8 @@ int main(void)
SPI_select eeprom_cs(PORT->Group[1], 11);
//Input button(PORT->Group[0], PIN_PA25, true);
Input button(PORT->Group[0], PIN_PA12, true);
button.set_pull_up();
......@@ -87,8 +92,8 @@ int main(void)
separator[0].off();
separator[1]. on();
separator[0].on();
separator[1].on();
//led.set_driver_strength(Output::DRIVER_STRENGTH_STRONGER);
//button.set_pull_up();
......@@ -154,5 +159,46 @@ int main(void)
adc.done = false;
led.toggle();
}
if (button.is_set())
{
boost.disable();
uart.send("Disabled...");
}
if (dosomething)
{
uart.send("Voltage 12V:\t");
uart.send_dec(adc.value[adc.VOLTAGE_12V]/1000);uart.send('.');uart.send_dec(adc.value[adc.VOLTAGE_12V]%1000);
uart.send_new_line();
uart.send("Voltage 180V:\t");
uart.send_dec(adc.value[adc.VOLTAGE_180V]/1000);uart.send('.');uart.send_dec(adc.value[adc.VOLTAGE_180V]%1000);
uart.send_new_line();
uart.send("Current 12V:\t");
uart.send_dec(adc.value[adc.CURRENT_12V]/1000);uart.send('.');uart.send_dec(adc.value[adc.CURRENT_12V]%1000);
uart.send_new_line();
uart.send("Current 180V:\t");
uart.send_dec(adc.value[adc.CURRENT_180V]/1000);uart.send('.');uart.send_dec(adc.value[adc.CURRENT_180V]%1000);
uart.send_new_line();
uart.send("Ambient light:\t");
uart.send_dec(adc.value[adc.AMBIENT_LIGHT]);
uart.send_new_line();
uart.send("Temp boost:\t");
uart.send_dec(adc.value[adc.TEMPERATURE_BOOST]/100);uart.send('.');uart.send_dec(adc.value[adc.TEMPERATURE_BOOST]%100);
uart.send_new_line();
uart.send("Temp ambient:\t");
uart.send_dec(adc.value[adc.TEMPERATURE_AMBIENT]/100);uart.send('.');uart.send_dec(adc.value[adc.TEMPERATURE_AMBIENT]%100);
uart.send_new_line();
uart.send_new_line();
dosomething = false;
}
}
}
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 to comment