Skip to content
Snippets Groups Projects
Commit 27fd0a84 authored by Will Langford's avatar Will Langford
Browse files

adding firmware

parent 7aa7f8fb
Branches
No related tags found
No related merge requests found
Pipeline #
Will
Will-RMBP
14.03.2018 15:55.50
20.03.2018 17:37.16
Will
Will-RMBP
14.03.2018 15:55.50
20.03.2018 17:37.16
//
// hello.dac.8E5.c
//
// 8E5 dac
//
#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
uint16_t lookup[128] = {
2047, 2147, 2247, 2347, 2446, 2544, 2641, 2736, 2830, 2922, 3011, 3099, 3184, 3266, 3345, 3421, 3494, 3563, 3629, 3691, 3749, 3802, 3852, 3897, 3938, 3974, 4005, 4032, 4054, 4071, 4084, 4091, 4094, 4091, 4084, 4071, 4054, 4032, 4005, 3974, 3938, 3897, 3852, 3802, 3749, 3691, 3629, 3563, 3494, 3421, 3345, 3266, 3184, 3099, 3011, 2922, 2830, 2736, 2641, 2544, 2446, 2347, 2247, 2147, 2047, 1947, 1847, 1747, 1648, 1550, 1453, 1358, 1264, 1172, 1083, 995, 910, 828, 749, 673, 600, 531, 465, 403, 345, 292, 242, 197, 156, 120, 89, 62, 40, 23, 10, 3, 0, 3, 10, 23, 40, 62, 89, 120, 156, 197, 242, 292, 345, 403, 465, 531, 600, 673, 749, 828, 910, 995, 1083, 1172, 1264, 1358, 1453, 1550, 1648, 1747, 1847, 1947
};
int main(void) {
//
// main
//
uint16_t angle=0;
//
// set up clock
//
//OSC.CTRL = OSC_RC32MEN_bm; // enable 32MHz clock
//while (!(OSC.STATUS & OSC_RC32MRDY_bm)); // wait for clock to be ready
//CCP = CCP_IOREG_gc; // enable protected register change
//CLK.CTRL = CLK_SCLKSEL_RC32M_gc; // switch to 32MHz clock
OSC.PLLCTRL = OSC_PLLFAC4_bm | OSC_PLLFAC3_bm; // 2 MHz * 24 = 48 MHz
OSC.CTRL = OSC_PLLEN_bm; // enable PLL
while (!(OSC.STATUS & OSC_PLLRDY_bm)); // wait for PLL to be ready
CCP = CCP_IOREG_gc; // enable protected register change
CLK.CTRL = CLK_SCLKSEL_PLL_gc; // switch to PLL
//set up dac
DACA.CTRLB = ( DACA.CTRLB & ~DAC_CHSEL_gm ) | DAC_CHSEL_DUAL_gc;
DACA.CTRLC = ( DACA.CTRLC & ~( DAC_REFSEL_gm | DAC_LEFTADJ_bm ) ) | DAC_REFSEL_AVCC_gc;
DACA.CTRLA = ( DACA.CTRLA & ~DAC_CH1EN_bm ) | DAC_CH0EN_bm | DAC_ENABLE_bm;
while(1){
DACA.CH0DATA = lookup[angle];
angle = (angle+1)%128;
}
}
PROJECT=hello.128a4u.dac
SOURCES=$(PROJECT).c
MMCU=avrxmega7
F_CPU = 32000000
TARGET = x128a4u
PROGRAMMER= atmelice_pdi
CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU)
$(PROJECT).hex: $(PROJECT).out
avr-objcopy -O ihex $(PROJECT).out $(PROJECT).c.hex;\
avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out
$(PROJECT).out: $(SOURCES)
avr-gcc $(CFLAGS) -I./ -o $(PROJECT).out $(SOURCES)
program: $(PROJECT).hex
avrdude -p $(TARGET) -c $(PROGRAMMER) -U flash:w:$(PROJECT).c.hex
......@@ -74,7 +74,7 @@ My understanding of the waveform:
- High-side gate drivers: [LM5107](http://www.ti.com/lit/ds/symlink/lm5107.pdf) [UCC27200A](https://www.digikey.com/product-detail/en/texas-instruments/UCC27201ADDAR/296-28428-1-ND/2638108)
- I could get away with just using one of these (and using a low-side mosfet to do the discharge control). The problem with this is that then the workpiece and worktable are at high voltages whenever the machine is on. So I suspect I'll go with two...
- Capacitor: [6.8uF conductive polymer](https://www.digikey.com/scripts/DkSearch/dksus.dll?Detail&itemSeq=254554510&uq=636564567701952216)
- 3.3V switching regulator: https://www.digikey.com/scripts/DkSearch/dksus.dll?Detail&itemSeq=254578769&uq=636564653321122626
- 3.3V switching regulator: https://www.digikey.com/scripts/DkSearch/dksus.dll?Detail&itemSeq=254721636&uq=636571622259993391
- window comparator
- http://www.ti.com/lit/ug/tidub01/tidub01.pdf
- just need 1 x (4x) https://www.digikey.com/product-detail/en/texas-instruments/TLV1704AIPWR/296-38432-1-ND/5015597
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment