вот подправил (слегка еще подформатировал) [+][или по ссылке ->] http://upload.caxapa.ru/main.c
#include <iom128.h>
#include <inavr.h>
#define b00000000 0
#define b00000001 1
#define b00000010 2
#define b00000100 4
#define b00001000 8
#define b00010000 16
#define b00100000 32
#define b01000000 64
#define b10000000 128
#define un 0
const char mass_time [] = {50, 51, 52, 53, 100, 100, 100, 100, 100};
const char mass_channel [] = { 0, 2, 3, 6, 7, 1, 4, 5, 8};
void main (void)
{
char j, k, i, a;
char number = 24; //число каналов шим
char time[24], channel[24]; //таблица уставок
char pwmtable [4][24]; //рабочая таблица
char pattern [3][24] = {
b00000001, b00000000, b00000000,
b00000010, b00000000, b00000000,
b00000100, b00000000, b00000000,
b00001000, b00000000, b00000000,
b00010000, b00000000, b00000000,
b00100000, b00000000, b00000000,
b01000000, b00000000, b00000000,
b10000000, b00000001, b00000000,
b00000000, b00000010, b00000001,
b00000000, b00000100, b00000000,
b00000000, b00001000, b00000000,
b00000000, b00010000, b00000000,
b00000000, b00100000, b00000000,
b00000000, b01000000, b00000000,
b00000000, b10000000, b00000000,
b00000000, b00000000, b00000001,
b00000000, b00000000, b00000010,
b00000000, b00000000, b00000100,
b00000000, b00000000, b00001000,
b00000000, b00000000, b00010000,
b00000000, b00000000, b00100000,
b00000000, b00000000, b01000000,
b00000000, b00000000, b10000000
};
//Упорядочение входных уставок по времени
for(i = 0; i < number; i++)
{
k = i;
for(j = i + 1; j < number; j++)
{
if(time[i] > time[j]) k = j;
}
if (k != i)
{
a = time[i];
time[i] = time[j];
time[j] = a;
a = channel[i];
channel[i] = channel[j];
channel[j] = a;
}
}
//Формирование рабочей таблицы очередного шим
pwmtable[0][0] = time[0];
pwmtable[1][0] = pattern[1][channel[0]];
pwmtable[2][0] = pattern[2][channel[0]];
pwmtable[3][0] = pattern[3][channel[0]];
k = 0;
for(i = 0; i < number; i++)
{
if(pwmtable[0][k] = time[i])
{
pwmtable[0][k] = time[i];
pwmtable[1][k] |= pattern[1][channel[i]];
pwmtable[2][k] |= pattern[2][channel[i]];
pwmtable[3][k] |= pattern[3][channel[i]];
}
else
{
pwmtable[0][k+1] = time[i];
pwmtable[1][k+1] = pwmtable[1][k] | pattern[1][channel[i]];
pwmtable[2][k+1] = pwmtable[2][k] | pattern[2][channel[i]];
pwmtable[3][k+1] = pwmtable[3][k] | pattern[3][channel[i]];
k++;
}
}
//Для входных уставок
for (i = 0; i < 9; time[i] = mass_time[i], channel[i++] = mass_channel[i]);
}