f_14_13_temptst.c

来自「* Use 10 MHz crystal frequency. * Use 」· C语言 代码 · 共 47 行

C
47
字号
#include "config.h"#include "serial.c"#include "serio.c"#include "delay.h"#include "i2cmsu.c"#include "temp_module.c"void main(void){  unsigned char mode;  signed int temp2;  signed int temp_c, temp_f;  serial_init(95,1); // 19200 in HSPLL mode, crystal = 7.3728 MHz  if (!RI) {    RI = 1;    printf("Software reset!");pcrlf();    if (i2c_errstat) i2c_print_err();  }  if (!TO) {    printf("Watchdog timer reset has occurred.\n"); pcrlf();    if (i2c_errstat) i2c_print_err();  }  i2c_init(73); // ~100 kHz @ FOSC = 29.4912 MHz  pcrlf();  printf("Temp Sensor Test Started");  pcrlf();  SWDTEN = 1;  // enable watchdog timer  // set one shot mode  ds1621_send1(ACCESS_CONFIG,0x01);  while(1) {    // start conversion    ds1621_send0(START_CONVERT);    //wait for end    do{      mode = ds1621_read1(ACCESS_CONFIG);    }    while(!bittst(mode,7));    ds1621_read2(READ_TEMP,(unsigned char *)&temp2);    temp_c = (temp2 >> 8);    temp_f = (temp_c*9)/5 + 32;    pcrlf();    printf("Temp read: %x (16 bits), %d (C), %d (F)",      temp2,temp_c,temp_f);    // wait for key input for next conv.    getch();   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?