init.c File Reference

#include "lib_mcu/comparator/comparator_drv.h"

Include dependency graph for init.c:

Go to the source code of this file.

Functions

void init (void)


Function Documentation

void init ( void   ) 

ports direction configuration, timer 0 configuration, run the PLL, allow interruptions

Definition at line 29 of file init.c.

Referenced by main().

00030 {
00031    /*************************************************************************************/
00032    /*           ports direction configuration                                           */
00033    /*************************************************************************************/
00034 
00035    DDRB = 0xC3;
00036 //   DDRC = 0x89; MC200
00037    DDRC = 0x8A; //MC100
00038    DDRD = 0x01;
00039 //   DDRE = 0x02; // MC200
00040    DDRE = 0x04; // MC100
00041 
00042    PORTC = 0x06;     /* enable pull up */
00043 
00044    /*************************************************************************************/
00045    /*     Timer 0 Configuration : generates the sampling fréquency                      */
00046    /*************************************************************************************/
00047    TCCR0A = (1<<WGM01);   // mode CTC : Clear Timer on Compare
00048    TCCR0B = (1<<CS02);    // f_quartz = 8 MHz / 256 = 32 kHz
00049 //      OCR0A = 0x20;          // one interruption every 1.056ms @8 Mhz
00050 //      OCR0A = 0x10;          // one interruption every 0.544ms @8 Mhz
00051 //      OCR0A = 0x08;          // one interruption every 0.288ms @8 Mhz (0.144ms @16 Mhz)
00052 //   OCR0A = 0x02;          // one interruption every 48µS @16 Mhz
00053    OCR0A = 0x03;          // one interruption every 64µS @16 Mhz
00054 
00055 // !! 48µS is too quick for GCC , please use at least 64µS 
00056 //                                and adjust Prescaler_Main_Tick
00057 //                                in mc_drv.c
00058 
00059 
00060    TIMSK0 = (1<<OCIE0A);  // allow interruption when timer=compare
00061 
00062    init_comparator0();
00063    init_comparator1();
00064    init_comparator2();
00065 
00066 
00067 //    initialize external interrupts /* MC200 */
00068 
00069 //   EICRA =(0<<ISC21)|(1<<ISC20)|(0<<ISC11)|(1<<ISC10)|(0<<ISC01)|(1<<ISC00);
00070 //   EIFR = (1<<INTF2)|(1<<INTF1)|(1<<INTF0); // clear possible IT due to config
00071 //   EIMSK=(0<<INT2)|(1<<INT1)|(1<<INT0);
00072 
00073    Enable_interrupt();            // allow interruptions
00074 }

Here is the caller graph for this function:


Generated on Tue Sep 16 18:11:22 2008 for Atmel BLDC Sinusoidal on ATAVRMC100 by  doxygen 1.5.3