ation of hydrostatic transmission system with energy regeneration using hydraulic accumulator//Springer. Journal of Mechanical Science and Tehnology 24, 2 010
25. # justify gt; Додаток А
Лістинг програми.
# include lt; stdio.h gt;
//# include lt; c8051F040.h gt;
# include lt; variable.h gt; init_dac1 (void);
//void set_dac1 (void); OSCILLATOR_Init (void); init_timer3 (int counts); isr_timer3 (void); set_dac1 (unsigned char);
//void init_dac0 (void); i=0; char v=0x00; main (void)
{// while (1) {
//init_dac1 ();
//set_dac1 ();
//EA=1; }=0;=0xDE;=0xAD; _Init (); _ dac1 ();
//init_dac0 (); _ timer3 (SYSCLK/SAMPLE_RATE_DAC);=1; (1)
{
}
} OSCILLATOR_Init (void)
{SFRPAGE_SAVE=SFRPAGE;// Save Current SFR page=CONFIG_PAGE;// Set SFR page |=0x03;// Set internal oscillator to run
//at its maximum frequency=SFRPAGE_SAVE;// Restore SFR page
} init_dac1 (void)
{char SFRPAGE_SAVE=SFRPAGE;=LEGACY_PAGE; CN |=0x03;=DAC1_PAGE; CN=0x8C; L=0x00;=DAC0_PAGE; CN=0x84; L=0x00;
//DAC0H=0x00;=SFRPAGE_SAVE;
} set_dac1 (unsigned char H)
{char SFRPAGE_SAVE=SFRPAGE;=DAC1_PAGE; L=0x00; H=H;=SFRPAGE_SAVE;
} init_timer3 (int counts)
{char SFRPAGE_SAVE=SFRPAGE;
//SFRPAGE=TMR3_PAGE;=TMR3_PAGE; CF=0x00;// SYSCLK/12H=(-counts gt; gt; 4);// Reload value for XX HzL=(-counts lt; lt; 4);// Reload value for XX HzH=0xff; L=0xff;
//SFRPAGE=LEGACY_PAGE; |=0x01;// T3 interrupt enableCN=0x04;// T3 run=SFRPAGE_SAVE;
} isr_timer3 (void) interrupt 14
{TMR3CN amp;=~ (0x80); ++; (i lt;=75)
{++; _ dac1 (v);
}
/* else if (i lt;=125)
{set_dac1 (v);} */
{(i lt;=150)
{-; _ dac1 (v);
}
/* else if (i lt;=225)
{set_dac1 (v);} */{i=0;}
}