Skip to content

Instantly share code, notes, and snippets.

@jakabo27

jakabo27/Lab7Code.c

Last active Oct 2, 2019
Embed
What would you like to do?
#include <plib.h>
//This is here to make timing calculations easier!
#pragma config FPBDIV = DIV_2
//r is a Rest. The value doesn't matter, it just has to be unique (not another note)
#define r 3000
//I added another octave of notes that they didn't give us
//Cs = C sharp. Eb = E flat. Everything else is normal.
//lowest notes
#define a 4545
#define as 4292
#define bb 4292
#define b 4050
#define C 3817
#define Cs 3610
#define Db 3610
#define D 3402
#define Ds 3216
#define Eb 3216
#define E 3031
#define F 2866
#define Fs 2703
#define Gb 2703
#define G 2551
#define Gs 2410
#define Ab 2410
#define A 2273
#define As 2146
#define Bb 2146
#define B 2025
#define CC 1911
#define CCs 1805
#define DDb 1805
#define DD 1701
#define DDs 1608
#define EEb 1608
#define EE 1515
//highest notes
//Our base note duration - change this to make your song play faster or slower.
#define t4 400
//t2 = half notet4 = quarter note. t8 = eighth note. Etc
#define t2 t4*2
#define t1 t2*2
#define t8 t4/2
#define t16 t8/2
#define t32 t16/2
//dotted notes - dq or d4 = dotted quarter, etc
#define dh t2+t4
#define d2 t2+t4
#define d4 t4+t8
#define dq t4+t8
#define d8 t8+t16
#define d16 t16+t32
//define the number of notes in your song as num_notes
/*Initialize global variables*/
//Interrupt Function
void __ISR(8) WhyDidTheChickenCrossTheRoad(void){
//important stuff, good luck
}
main()
{
//Setup Timers/Interrupts - enable and priority
//Disable Gated time accumulation, use 16-bit, internal clock, no prescale
note = 0; //Start at the beginning of the song
while(1)//Run Continuously
{
//Do the thing man
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment