Додаток 2
Лістинг програми
мікроконтролер магнітола програма
# include /* special function register declarations */
# include /* prototype declarations for I/O functions */
# ifdef MONITOR51/* Debugging with Monitor-51 needs */code reserve [3] _at_ 0x23;/* space for serial interrupt if */
# endif/* Stop Exection with Serial Intr. */Char dacnastr;// uroven U dla nastroiki priemnikabolch_mench = P3 ^ 3 ;//upravlen tranzistoramiFM = P0 ^ 6; am = P0 ^ 7; upravl = P0 ^ 2; sda = 0; scl = 0; rs = 0; e = 0; char takt, uprbyte; char key, keyold; char regim;// char reginmagnit;// char param [] = {10,0,0};// gromk bass & trablechar bas;// char treble ;// char regimplai; char unastr;// stupen nastrchar pp, i, j, n; char parametr; char line ;//input line CD Magn, Radiochar sot, sek, min, chas; char lcd1 [] = {0 , 0,0,0,0,0,0,0,0,0,0,0}; char lcd2 [] = {0,0,0,0,0,0,0,0,0,0, 0,0}; char cd [] = {0x5F, 0x43, 0x44, 0x2D, ​​0x50, 0x4C, 0x41, 0x45, 0x52, 0x5F, 0x5F, 0x5F}; char tuner [] = {0x5F, 0x54, 0x55, 0x4E, 0x45, 0x52, 0x5F, 0x, 0x, 0x, 0x, 0x}; char mag [] = {0x5F, 0x4D, 0x41, 0x47, 0x4E, 0x49, 0x54, 0x4F, 0x4C, 0x41, 0x5F, 0x5F}; delay ( void)// timeout na 5mks)
{char k; (k = 0; k <4; k + +);
} i2c (void)// timeout na 5mks)
{(n = 0; n <4; n + +)// peredat 4 parametra
{= 1; delay (); sda = 0 ;//start puls = 0xc0 ;//koman write parametr (j = 0; j <8; j + +)
{scl = 0; delay (); pp = pp>> 1; sda = CY; delay (); scl = 1; delay (); delay ();} (n <3 )
{= param [n]; if (n == 1) pp = pp | 0xc0; if (n == 2) pp = pp | 0x80; (j = 0; j <8; j + +)
{scl = 0; delay (); pp = pp>> 1; sda = CY; delay (); scl = 1; delay (); delay ();}
}
{pp = line | 0xe0 ;//set input line (j = 0; j <8; j + +)
{scl = 0; delay (); pp = pp>> 1; sda = CY; delay (); scl = 1; delay (); delay ();}}
}
} 0int0 (void) interrupt 0 using 1
{= P1; (keyold == 0) && (key == 1)
{= key; param [parametr] + +; if
} (keyold == 1) && (key == 0)
{keyold = key; param [parametr] -; if
} (keyold! = 2) && (key == 2) {line = 0; for (j = 0; j <12; j + +) lcd1 [j] = cd [j ];}// CD line (keyold! = 3) && (key == 3) {line = 1; for (j = 0; j <12; j + +) lcd1 [j] = tuner [j]; }// Tuner (keyold! = 4) && (key == 4) {line = 2; for (j = 0; j <12; j + +) lcd1 [j] = mag [j];}// Magnitofon (line == 2)
{if (keyold! = 5) && (key == 5) {upravl = 0; P2 = 0x10; upravl = 1;}// peremotka left...