Пишем алгоритм обхода массива двумя способами.
Спойлер
И видим, что начхал компилятор на счётчик цикла и сгенерировал одинаковый бит в бит код для обоих вариантов.
Код: Выделить всё
void Send_DAT16(uint16_t dat){
CS_LOY; //ChipSelect loy
DC_H; //DC H
SPI1->CR1 |= SPI_CR1_CRCL;
while (!(SPI1->SR & SPI_SR_TXE)){};
SPI1->DR = dat;
while (!(SPI1->SR & SPI_SR_TXE)){};
while ((SPI1->SR & SPI_SR_BSY)){};
CS_H;//ChipSelect Up
}Код: Выделить всё
*((__IO uint16_t *)&SPI1->DR) = dat;Код: Выделить всё
void Send_DAT16(uint16_t dat){
uint8_t bytes[2];
bytes[0] = dat >> 8; // high byte (0x12)
bytes[1] = dat & 0x00FF; // low byte (0x34)
Send_DAT(bytes[0]);
Send_DAT(bytes[1]);
}
Код: Выделить всё
SPI1->DR = __REV16(dat);Код: Выделить всё
SPI1->DR = __REV16(dat);
Код: Выделить всё
SPI1->DR = __REV16(dat);Код: Выделить всё
for(auto &x : InitAtray)Код: Выделить всё
CONTAINER::iterator it = InitAtray.begin();
while (it != InitAtray.end()) {
TYPE &x = *(it++);
/*
cделать что-то с x
*/
}
Код: Выделить всё
uint8_t wavbuf0[512];
uint8_t wavbuf1[512];
uint16_t NmbrByte; //Number of byte to Audio Play
uint8_t Numbuf; //Number of played buffer
volatile uint8_t Empflug; //Flug is Empry Buffer
uint32_t sizefile;
uint16_t i,j,k,n,tag;
Код: Выделить всё
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if (htim->Instance == TIM2){
if(Numbuf==0) __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,wavbuf0[NmbrByte]);
if(Numbuf==1) __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,wavbuf1[NmbrByte]);
NmbrByte++;
if(NmbrByte>511){
Empflug=1;
NmbrByte=0;
Numbuf++;
//if (Numbuf>1)Numbuf=0;
Numbuf = Numbuf & 0x01;
printf(" %d",Empflug);
printf(" %d;",Numbuf);
}
}
}Код: Выделить всё
HAL_Delay(100);
printf("Start is Mount\n");
fres = f_mount(&FatFs, "", 1);
if (fres == FR_OK) {
printf("Mount is OK\n");
} else {
printf("Error code %d\n", fres);
}
char path[30] = "00-01-radio-mayak.wav";
fres = f_open(&file, (char*)path, FA_READ);
if (fres == FR_OK) {
printf("Open file: %s\n",path);
printf(" \n");
fres = f_stat((char*)path, &fno);
if (fres == FR_OK) {
sizefile = fno.fsize;
n=sizefile/512;
tag=sizefile%512;
if(sizefile<1536){n=3;tag=0;}
printf("Size of file %s: %lu bytes\n", path, sizefile);
printf("512B blocks is %d full and tag %d Bytes\n",n,tag);
fres = f_read(&file, wavbuf0, 512, &bytes_read);
printf("512B read\n");
Numbuf=0;
fres = f_read(&file, wavbuf1, 512, &bytes_read);
Empflug=0;
n=n-1;
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
printf("PWM started\n");
NmbrByte=0;
HAL_TIM_Base_Start_IT(&htim2);
printf("%d\n",n);
for(i=0;i<n;i++){
while(Empflug==0);
if(Empflug==1){
if(Numbuf==0) fres = f_read(&file, wavbuf1, 512, &bytes_read);
if(Numbuf==1) fres = f_read(&file, wavbuf0, 512, &bytes_read);
Empflug=0;
}
}
}
HAL_TIM_Base_Stop_IT(&htim2);
f_close(&file);
printf("End the file\n");
} else {
printf("Error Open File Code: %d\n", fres);
}Уош писал(а):Что значит, не видит? выдаёт ошибку? или в отладчике исчезает?
Код: Выделить всё
if(Numbuf==0) __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,wavbuf0[NmbrByte]);
if(Numbuf==1) __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,wavbuf1[NmbrByte]);Код: Выделить всё
if(!Numbuf) __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,wavbuf0[NmbrByte])
else __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,wavbuf1[NmbrByte]);Код: Выделить всё
__HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1, Numbuf?wavbuf1[NmbrByte]:wavbuf0[NmbrByte]); // а здесь комментарий бы написалКод: Выделить всё
Numbuf++;
//if (Numbuf>1)Numbuf=0;
Numbuf = Numbuf & 0x01;Код: Выделить всё
Numbuf ^= 1;
Уош писал(а):Что значит, не видит? выдаёт ошибку? или в отладчике исчезает?