heat control  r71
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
init.c
Go to the documentation of this file.
1 #include "timer.h"
2 #include "init.h"
3 #include "adc.h"
4 #include "lcdisp.h"
5 #include "comm.h"
6 #include "setup.h"
7 
11 void Init(void) {
12  extern MEASSET g_sets[NUM_MS];
13  UCHAR i=0;
14 
15  // done individually by LCD init
16 // DDRA=(0<<DDA7) | (0<<DDA6) | (0<<DDA5) | (0<<DDA4) | (0<<DDA3) | (0<<DDA2) | (0<<DDA1) | (0<<DDA0);
17  // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
18 // PORTA=(0<<PORTA7) | (0<<PORTA6) | (0<<PORTA5) | (0<<PORTA4) | (0<<PORTA3) | (0<<PORTA2) | (0<<PORTA1) | (0<<PORTA0);
19 
20  // Port B initialization
21 // DDRB - Port B Data Direction Register
22 // | DDB7 [0] | DDB6 [0] | DDB5 [0] | DDB4 [1] | DDB3 [1] | DDB2 [0] | DDB1 [0] | DDB0 [0] |
23 // configure PB3 & PB4 as output
24  DDRB=(0<<DDB7) | (0<<DDB6) | (0<<DDB5) | (1<<DDB4) | (1<<DDB3) | (0<<DDB2) | (0<<DDB1) | (0<<DDB0);
25 
26 // PORTB - Port B Data Register
27 // | PORTB7 [0] | PORTB6 [0] | PORTB5 [0] | PORTB4 [0] | PORTB3 [0] | PORTB2 [0] | PORTB1 [0] | PORTB0 [0] |
28  PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);
29 
30 // ACSRA - Analog Comparator Control and Status Register A
31 // | ACD [1] | ACBG [0] | ACO [0] | ACI [0] | ACIE [0] | ACME [0] | ACIS1 [0] | ACIS0 [0] |
32 // set ACD bit to '1' to disable analog comparator
33  AC_SR = (1<<ACD) | (0<<ACBG) | (0<<ACO) | (0<<ACI) | (0<<ACIE) | (0<<ACME) | (0<<ACIS1) | (0<<ACIS0);
34 
35 // clock prescaler setup - division factor = 1 (@ system clock = 8 MHz)
36  CLKPR = (1<<CLKPCE) | (0<<CLKPS3) | (0<<CLKPS2) | (0<<CLKPS1) | (0<<CLKPS0);
37  CLKPR = (0<<CLKPCE) | (0<<CLKPS3) | (0<<CLKPS2) | (0<<CLKPS1) | (0<<CLKPS0);
38 
39  TimerInit();
40  AdcInit();
41  CommInit();
42  SetupInit();
43  LcdInit();
44  //invalidate values of measurement sets
45  for(i=0;i<NUM_MS;++i) {
46  g_sets[i].inTemp = INVALID_VAL_I16;
47  g_sets[i].outTemp = INVALID_VAL_I16;
48  g_sets[i].forTemp = INVALID_VAL_U16;
49  }
50 }
51 
52 
53 
void TimerInit(void)
initialize timer resource period: 32┬Ás
Definition: timer.c:38
void Init(void)
Definition: init.c:11
#define INVALID_VAL_I16
Definition: types.h:109
MEASSET g_sets[NUM_MS]
Definition: hc.c:35
#define UCHAR
Definition: types.h:73
void LcdInit(void)
display initialization Alphanumeric LCD initialization Connections are specified in the Project|Confi...
Definition: lcdisp.c:23
void AdcInit(void)
initialize the adc resource
Definition: adc.c:23
INT inTemp
Definition: types.h:210
UINT forTemp
Definition: types.h:218
void SetupInit(void)
setup initialization at startup
Definition: setup.c:50
#define INVALID_VAL_U16
Definition: types.h:105
#define AC_SR
Definition: types.h:44
#define NUM_MS
Definition: types.h:223
void CommInit(void)
init as defined in "doc4300.pdf": figure 12. Initialization of the Receive Driver ...
Definition: comm.c:27
INT outTemp
Definition: types.h:214
Definition: types.h:206