fizo741
Member level 1
- Joined
- Aug 10, 2012
- Messages
- 34
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Tehran/Iran
- Activity points
- 1,539
Hi
Ive written these codes with help of app note to initiate mlx90614 but there are 2 errors in codevision so I cant debug my program to avrstudio4 to test it.It isnt complete actually.Can any one help me to undersatand where is wrong or what changes i should do?
Best regards
Ive written these codes with help of app note to initiate mlx90614 but there are 2 errors in codevision so I cant debug my program to avrstudio4 to test it.It isnt complete actually.Can any one help me to undersatand where is wrong or what changes i should do?
Best regards
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 /***************************************************** This program was produced by the CodeWizardAVR V2.05.0 Evaluation Automatic Program Generator © Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l. [url]http://www.hpinfotech.com[/url] Project : Version : Date : 8/25/2012 Author : Freeware, for evaluation and non-commercial use only Company : Comments: Chip type : ATmega16L Program type : Application AVR Core Clock frequency: 2.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega16.h> #include<delay.h> Alphanumeric LCD Module functions #include <alcd.h> #define SCL PORTC.0 #define SDA PORTC.1 #define SDA_HIGH SDA=1 #define SDA_LOW SDA=0 #define SCL_HIGH SCL=1 #define SCL_LOW SCL=0 #define RAM_Access 0X00 #define RAM_Tobj1 0x07 #define SA 0x5A #define EEPROM_Access 0x20 #define HIGHLEV 3 #define LOWLEV 1 void START_bit() ; void STOP_bit(); void DummyCommand(unsigned char byte); void TX_byte(unsigned char); void send_bit(unsigned char bit_out); unsigned char Receive_bit(void); float CalcTemp1(unsigned int data1); float CalcTemp1(unsigned int data1); unsigned char RX_byte(unsigned char RX_buffer,unsigned char Bit_Counter); void main(void) { unsigned char SlaveAddress ; unsigned char command; unsigned int data1,data2; float t1,t2; START_bit(); SlaveAddress=SA<<1; command=RAM_Access|RAM_Tobj1; DummyCommand(SlaveAddress); delay_ms(200); STOP_bit(); PORTA=0x00; DDRA=0xFF; // Alphanumeric LCD initialization // Connections specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTA Bit 0 // RD - PORTA Bit 1 // EN - PORTA Bit 2 // D4 - PORTA Bit 4 // D5 - PORTA Bit 5 // D6 - PORTA Bit 6 // D7 - PORTA Bit 7 // Characters/line: 16 lcd_init(16); while (1) { } } void START_bit() { SDA_HIGH ; delay_ms(0.005); SCL_HIGH; delay_ms(0.005); SDA_LOW; delay_ms(0.005 ); SCL_LOW; delay_ms(0.005 ); } void STOP_bit(void) { SCL_LOW; delay_ms(0.005); SDA_LOW; delay_ms(0.005); SCL_HIGH; delay_ms(0.005); SDA_HIGH; delay_ms(0.005); } void send_bit(unsigned char bit_out ) { if(bit_out==0) SDA_LOW; else SDA_HIGH; delay_ms(0.05); SCL_HIGH; delay_ms(3000); SCL_LOW; SDA_HIGH; } unsigned char Receive_bit(void) { unsigned char Ack_bit; SCL_HIGH; delay_ms(3000); if(SDA==1) Ack_bit=1; else Ack_bit=0; SCL_LOW; delay_ms(1000); return Ack_bit; } void TX_byte(unsigned char Tx_buffer) { unsigned char Bit_counter; unsigned char Ack_bit; unsigned char bit_out; for(Bit_counter=8;Bit_counter>=1;Bit_counter--) { if(Tx_buffer&0x80==1) bit_out=1; else bit_out=0; send_bit(unsigned char bit_out ); Tx_buffer<<=1; } Ack_bit=Receive_bit(); } void DummyCommand(unsigned char Tx_buffer) { START_bit(); TX_byte(unsigned char Tx_buffer ); STOP_bit(); } float CalcTemp1(unsigned int data1) { float temp1; temp1=(data1*0.02)-273.15; return temp1; } float CalcTemp2(unsigned int data2) { float temp2; temp2=(data2*0.02)-273.15; return temp2; } unsigned char RX_byte(unsigned char RX_buffer,unsigned char Bit_Counter) { usigned char RX_buffer; unsigned char Bit_Counter; for(Bit_Counter=8;Bit_Counter>=1;Bit_Counter--) { if(Receive_bit()==1) { SDA_HIGH; RX_buffer<<1; } else { SDA_LOW; RX_buffer<<=1; } } return RX_buffer; }
Last edited by a moderator: