From 0a22bb3f6264b8b431e13a594c16ba9f80ea47cc Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sat, 10 Jun 2017 20:38:40 +0200 Subject: Fix --- floppyMusic/floppy.c | 14 ++- floppyMusic/floppy.h | 2 + floppyMusic/floppyMusic.componentinfo.xml | 2 +- floppyMusic/floppyMusic.cproj | 139 +++++++++++++++--------------- floppyMusic/main.c | 18 ++-- 5 files changed, 95 insertions(+), 80 deletions(-) (limited to 'floppyMusic') diff --git a/floppyMusic/floppy.c b/floppyMusic/floppy.c index e4eff05..440508b 100644 --- a/floppyMusic/floppy.c +++ b/floppyMusic/floppy.c @@ -17,7 +17,7 @@ ISR(TIMER0_OVF_vect) for(uint8_t i = 0; i < 8; i++) { - if(floppy_nextrun[i] == (timer_overflow_counter + 1)) + if(floppy_nextrun[i] == timer_overflow_counter ) { floppy_nextrun[i] += floppy_frequencies[i]; floppy_pulse(i); @@ -34,7 +34,7 @@ void floppy_setup(char *_pulse_port, char *_pulse_ddr, char *_direction_port, ch fDDR = _pulse_ddr; dPORT = _direction_port; dDDR = _direction_ddr; - + *fDDR = 0xff; *fPORT = 0xff; *dDDR = 0xff; @@ -58,17 +58,20 @@ void floppy_setup(char *_pulse_port, char *_pulse_ddr, char *_direction_port, ch *fPORT ^= 0xff; } + *dPORT = 0x00; *fPORT = 0xff; //Setup Timer TCCR0 |= (1 << CS01); // Prescaler 8 To leave enough time for ISR to complete TIMSK |= (1 << TOIE0); //Activate Interrupt + sei(); } void floppy_set_frequency(uint8_t _floppy_id, uint8_t _freq) { - floppy_frequencies[_floppy_id] = floppy_nextrun[_floppy_id] = _freq; + floppy_frequencies[_floppy_id] = _freq; + floppy_nextrun[_floppy_id] = _freq + timer_overflow_counter; } void floppy_pulse(uint8_t _floppy_id) @@ -82,4 +85,9 @@ void floppy_setup(char *_pulse_port, char *_pulse_ddr, char *_direction_port, ch *dPORT ^= (1<<_floppy_id); floppy_head_return_counter[_floppy_id] = 0; } + } + + int floppy_calc_freq(uint32_t _f_hz) + { + } \ No newline at end of file diff --git a/floppyMusic/floppy.h b/floppyMusic/floppy.h index 76ad123..f8b1c26 100644 --- a/floppyMusic/floppy.h +++ b/floppyMusic/floppy.h @@ -30,5 +30,7 @@ void floppy_set_frequency(uint8_t _floppy_id, uint8_t _freq); void floppy_pulse(uint8_t _floppy_id); +int floppy_calc_freq(uint32_t _f_hz); + #endif /* FLOPPY_H_ */ \ No newline at end of file diff --git a/floppyMusic/floppyMusic.componentinfo.xml b/floppyMusic/floppyMusic.componentinfo.xml index 7c3c717..ebbfd74 100644 --- a/floppyMusic/floppyMusic.componentinfo.xml +++ b/floppyMusic/floppyMusic.componentinfo.xml @@ -41,7 +41,7 @@ template source C Exe - 6uB4FLeVljduSJojLjAg+A== + GD1k8YYhulqRs6FD1B2Hog== templates/main.c Main file (.c) diff --git a/floppyMusic/floppyMusic.cproj b/floppyMusic/floppyMusic.cproj index 9910c79..9c197cc 100644 --- a/floppyMusic/floppyMusic.cproj +++ b/floppyMusic/floppyMusic.cproj @@ -45,8 +45,7 @@ - - + ISP custom @@ -83,79 +82,79 @@ - -mmcu=atmega8 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8" - True - True - True - True - False - True - True - - - NDEBUG - - - - - %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include - - - Optimize for size (-Os) - True - True - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include - - - + -mmcu=atmega8 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + - -mmcu=atmega8 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8" - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include - - - Optimize (-O1) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include - - - Default (-Wa,-g) - + -mmcu=atmega8 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Default (-Wa,-g) + diff --git a/floppyMusic/main.c b/floppyMusic/main.c index c0db582..09ca8d0 100644 --- a/floppyMusic/main.c +++ b/floppyMusic/main.c @@ -12,19 +12,25 @@ #include #include "floppy.h" -#include "uart.h" +//#include "uart.h" int main(void) { - uart_init(9600); + //uart_init(9600); + //DDRC = 0xff; + floppy_setup(&PORTC, &DDRC, &PORTB, &DDRB); + floppy_set_frequency(0, 70); - floppy_setup(&PORTC, &DDRC, &PORTD, &DDRD); - floppy_set_frequency(0, 4); + DDRD = 0xff; - uart_send_string("Floppy Music\n"); + PORTD = 0xff; //DEBUG + //uart_send_string("Floppy Music\n"); while (1) { - floppy_set_frequency(0, uart_recieve()); + //floppy_set_frequency(0, uart_recieve()); + //uart_send_string("Floppy Music\n"); + //_delay_ms(500); + //PORTD ^= 0xff; } } \ No newline at end of file -- cgit v1.2.3