Skip to content

Instantly share code, notes, and snippets.

@mipsparc mipsparc/osc.c
Created Oct 28, 2018

Embed
What would you like to do?
ハンドメイド電子回路「連絡ブザくん」ソースコード。波形データを入れ替えると、任意波形が発生できるぞ!
#include "mcc_generated_files/mcc.h"
void setNextLevel(void);
unsigned char curve1[] = {
39, 40, 26, 56, 39, 14, 58, 34, 46, 47, 39, 44, 37, 34, 37, 32, 28,
39, 38, 39, 47, 45, 42, 45, 40, 37, 37, 29, 39, 39, 32, 45, 45, 37,
39, 37, 37, 36, 34, 38, 39, 43, 46, 42, 42, 41, 38, 37, 40, 36, 34,
37, 37, 37, 41,
};
unsigned int seq_num = 0;
void setNextLevel(void)
{
PWM6_LoadDutyValue(curve0[seq_num]);
if (seq_num < 31) {
seq_num++;
} else {
seq_num = 0;
}
}
void main(void)
{
extern volatile uint16_t timer0ReloadVal16bit;
SYSTEM_Initialize();
INTERRUPT_GlobalInterruptEnable();
INTERRUPT_PeripheralInterruptEnable();
TMR0_SetInterruptHandler(setNextLevel);
timer0ReloadVal16bit = 0xFEB8; //40.4us
TMR0_WriteTimer(timer0ReloadVal16bit);
while (1) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.