attiny26 зарядное

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From Russian to

Threaded View
Hello All!


http://www.solarskit.wz.cz/tinych.html



















http://dr-shost.com/files/tinych.c










Sasha  http://dr-shost.com http://shostatsky.narod.ru [Team OS/2][Team EDSMO]




attiny26 зарядное
Sasha,

You wrote to All:


 SS> http://www.solarskit.wz.cz/tinych.html
 SS>


 SS>





 SS>

 SS>

 SS>

 SS>

 SS>

 SS> http://dr-shost.com/files/tinych.c
 SS>


 SS>



=== Begin of S_Timer.h ===
//===============================================================
#ifndef _S_TIMER_H_
#define _S_TIMER_H_

#ifdef S_TIMER_D
#define EXTERN
#else
#define EXTERN extern
#endif
//

EXTERN volatile unsigned int time_1ms;
EXTERN volatile unsigned int time_1sec;
EXTERN volatile unsigned int mmi_time;

EXTERN void  Init_Timer (void);
EXTERN void  Reset_Timer(void);

#endif /* __TIMER_H__ */

=== End of S_Timer.h =====


=== Begin of S_Timer.c ===
#define S_TIMER_D

#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>

#include <stdio.h>
#include <string.h>

//#include <avr/iocan128.h>
//#include <avr/iocanxx.h>

#include "macros.h"
#include "S_Timer.h"

//--------------------------------------------------------------------
//--- Timer Inizialisieren
//--------------------------------------------------------------------
void Init_Timer (void)
{
 time_1ms = 0;
 time_1sec = 0;
 mmi_time = 0;

 // ATMEGA128
  TCNT2 = 5;
 TIMSK  |= 0x40; //Timer/Counter2 Overflow Interrupt Enable
 TCCR2  = 0x6B;  //Fast PWM, Clear OC2 on compare match,
     // set OC2 at TOP, 64-> 1kHz = 1mS

 // AT90CAN128
/*
 TCNT2 = 5;
 TIMSK2  |= 0x01; //Timer/Counter2 Overflow Interrupt Enable
 TCCR2A  = 0x6C ; //Fast PWM, Clear OC2 on compare match,
          // set OC2 at TOP, 64-> 1kHz = 1mS
*/

}

//--------------------------------------------------------------------
//#pragma interrupt_handler  OCR2_CC_handler:iv_TIMER2_OVF
//void OCR2_CC_handler(void)

//--------------------------------------------------------------------
SIGNAL(SIG_OVERFLOW2)
{
 TCNT2 = 5;

 mmi_time++;
 time_1ms++;
 if (time_1ms == 1000)
 {
  time_1ms = 0;
  time_1sec++;
 }
}

//--------------------------------------------------------------------
// Timer Reset
//--------------------------------------------------------------------
void Reset_Timer(void)
{
 time_1ms = 0;
 time_1sec = 0;
 mmi_time = 0;
}
=== End of S_Timer.c =====





  while(1) {
           ...
           }








Andrey


Site Timeline