#include"io8535.h"
#define OCIE1A TIMSK_Bit4
#define I SREG_Bit7
#define DDD5 DDRD_Bit5
#define PD5 PORTD_Bit5
int COUNT;
__flash unsigned long NORAE[]={7198,5758,6398,7198,4798,4320,4798,4798,4320,3599,3838,4320,4798,5758,5399,4789,4320,4798,4798,5758,7198,6398,6398,6398,5758,6398,7198,5758,6398,7198,4798,4320,4798,4798,4320,3599,3838,4320,4798,3599,3199,3599,4320,4798,4320,4798,5758,6398,6398,4798,4798,5758,7198,6398,5758,5399,4798,4320,3838,3599,3199,3599,3838,4320,4798,7198,5758,4798,3599,3599,4798,5758,7198,6398,6398,4798,4798,7198};
__flash unsigned long COUNT1[]={256,320,288,256,384,427,384,384,427,512,480,427,384,320,342,384,427,384,384,320,256,288,288,288,320,288,256,320,288,256,384,427,384,384,427,512,480,427,384,512,576,512,427,384,427,384,320,288,288,384,384,320,256,288,320,342,384,427,480,512,576,512,480,427,384,256,320,384,512,512,384,320,256,288,288,384,384,256} ;
#pragma vector = TIMER1_COMPA_vect
__interrupt void COMP_A(void)
{
COUNT--;
}
void main(void)
{
DDD5 = 1;
PD5 = 1;
TCNT1H = 0;
TCNT1L = 0;
TCCR1A = 0x40;
OCIE1A = 1;
I = 1;
do{
int i;
for(i=0; i<80; i++){
OCR1AH = NORAE[i] >> 8;
OCR1AL = NORAE[i] & 0x00ff;
TCCR1B = 0x09;
COUNT = COUNT1[i];
while(COUNT != 0);
}
}while(1);
}
처음에는 이렇게 했는데 컴파일이 안되더라구요..
그래서 수정해서 이부분을
__flash unsigned long NORAE[]={7198,5758,6398,7198,4798,4320,4798,4798,4320,3599,3838,4320,4798,5758,5399,4789,4320,4798,4798,5758,7198,6398,6398,6398,5758,6398};
__flash unsigned long COUNT1[]={256,320,288,256,384,427,384,384,427,512,480,427,384,320,342,384,427,384,384,320,256,288,288,288,320,288,} ;
이렇게 수정하고 for 값에 i 를 i< 27로 수정했어요
그런데 돌아가긴 하는데 음이 너무 느린거 같아요 좀 떠 빠르면서 스타카토 식으루 음을 딱딱
타이머 인터럽트 조절 하시면 되겠네요