ハンドメイド電子回路「連絡ブザくん」ソースコード。波形データを入れ替えると、任意波形が発生できるぞ!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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