Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Edited by Luke Dunwell
- #include <MsTimer2.h> //See www.arduino.cc
- #include <avr/pgmspace.h>
- #define DATADDR DDRL
- #define DATAPORT PORTL
- #define BCDDR DDRB
- #define BCPORT PORTB
- #define BC1 0
- #define BDIR 2
- // BC2 = HIGH (that's for Hardware)
- const int ledPin = 52;
- extern prog_uint8_t rawData0[32752]; //As from C# prog
- byte buffer[16];
- int i = 0, j, led = 0;
- void send_data(unsigned char address, unsigned char data)
- {
- DATAPORT = address; // Write Address
- BCPORT |= ((1<<BDIR)|(1<<BC1)); // Validate Address
- delayMicroseconds(1);
- BCPORT &= ~((1<<BDIR)|(1<<BC1));
- DATAPORT = data; // Write Data
- BCPORT |= (1<<BDIR); // Validate Data
- delayMicroseconds(1);
- BCPORT &= ~(1<<BDIR);
- }
- void update(void)
- {
- digitalWrite(ledPin, led ^= 1);
- for(j=0; j<16; j++) send_data(j, pgm_read_byte_near(rawData0 + i + j));
- i += 16;
- if(i >= 32752) i = 0;
- }
- void setup(void)
- {
- // Configure Ports for PSG
- BCDDR |= ((1<<BC1)|(1<<BDIR));
- DATADDR = 0xFF;
- pinMode(ledPin, OUTPUT);
- // Deactivate PSG
- BCPORT &= ~((1<<BDIR)|(1<<BC1));
- // Start 50Hz Interrupt
- MsTimer2::set(20, update); // 20ms
- MsTimer2::start();
- }
- void loop(void)
- {
- // "whistle while you work"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement