Skip to content

Instantly share code, notes, and snippets.

@mipsparc
Created October 28, 2018 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mipsparc/adf2ebdc5d9960fdeb1a4143c82024f0 to your computer and use it in GitHub Desktop.
Save mipsparc/adf2ebdc5d9960fdeb1a4143c82024f0 to your computer and use it in GitHub Desktop.
ハンドメイド電子回路「連絡ブザくん」ソースコード。波形データを入れ替えると、任意波形が発生できるぞ!
#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