임베디드/고추건조기

완성 -1-

twoweeks-within 2024. 12. 18. 17:09


1. S/W 
          : 전원 > 저항 > s/w > gnd 
          // 전원 >  s/w 연결되면 > gnd : short 주의!
> GPIO_EXTIO ( interrupt ) : 누를때마다 인터럽트 발생
  PB0 : ON > 0, OFF > 1  
       > 누르면 전압 하강, 띄면 올라감
      > 눌렀을때 발생하려면 > 하강엣지 ( 옵션 : falling edge ) 
     <> 눌렀다 띄었을때 발생하면 > 상승엣지  
     > NVIC : 우선순위 3 정도
>>
누를때마다 it.c 파일 내 코드가 실행됨
   > ex) printf ("hello\r\n");

2.  START S/W
  // 1번과 동일

 

3. 온도센서 .. 처음부터 다시

bool Ds18b20_Init_Simple(void){

OneWire_Init(&OneWire,_DS18B20_GPIO ,_DS18B20_PIN);

// Init 하고

OneWire.ROM_NO[0] = 0x28;

OneWire.ROM_NO[1] = 0x3d;

OneWire.ROM_NO[2] = 0x8c;

OneWire.ROM_NO[3] = 0x95;

OneWire.ROM_NO[4] = 0xf0;

OneWire.ROM_NO[5] = 0x01;

OneWire.ROM_NO[6] = 0x3c;

OneWire.ROM_NO[7] = 0x67;

// ROM 가져온걸

OneWire_GetFullROM(&OneWire, ds18b20[TempSensorCount-1].Address);

// 주소 넣어주고

Ds18b20Delay(50);

 

DS18B20_SetResolution(&OneWire, ds18b20[i].Address, DS18B20_Resolution_12bits);

Ds18b20Delay(50);

 

DS18B20_DisableAlarmTemperature(&OneWire, ds18b20[i].Address);

return true;

}

 >> 

bool Ds18b20_ManualConvert(void)

{

 

Ds18b20Timeout=_DS18B20_CONVERT_TIMEOUT_MS/10;

DS18B20_StartAll(&OneWire); //온도 변환 시작. 

Ds18b20Delay(100);

while (!DS18B20_AllDone(&OneWire))  

// 온도변환이 끝났다? > break;

 /*

uint8_t DS18B20_AllDone(OneWire_t* OneWire)

{

return OneWire_ReadBit(OneWire);

/* If read bit is low, then device is not finished yet with calculation temperature */

 >> HIGH : devie is finished

 :  LOW 일때 값 읽고

 : HIGH : 끝난뒤 , 일상

*/

}

{

Ds18b20Delay(10);

Ds18b20Timeout-=1;

if(Ds18b20Timeout==0)

break;  

}

if(Ds18b20Timeout>0)

{

TemperSensor.DataIsValid = DS18B20_Read(&OneWire, TemperSensor.Address, &TemperSensor.Temperature);

}

else

{

TemperSensor.DataIsValid = false;

}

if(Ds18b20Timeout==0)

return false;

else

return true;

 

}

'임베디드 > 고추건조기' 카테고리의 다른 글

ADC  (1) 2024.12.24
SSD1306 코드분석  (0) 2024.12.17
I2C hello world :)  (0) 2024.12.17
I2C 구조  (0) 2024.12.15
코드 분해  (0) 2024.12.14