|

楼主 |
发表于 2021-1-21 22:43:24
|
显示全部楼层
今天晚上用esp32搭了个小板,准备调试功率板,但是始终没有输出。
计划等控制板来了用控制板调。
附测试程序:
- #include <Wire.h>
- #define SC8815_ADDR 0x74
- byte reg[0x20] = {0x00};
- void readReg() {
- Wire.beginTransmission(SC8815_ADDR);
- Wire.write(0x00);
- Wire.endTransmission();
- Wire.requestFrom(SC8815_ADDR, 0x18);
- for (int i = 0; i <= 0x17; i++)
- {
- reg[i] = Wire.read();
- }
-
- }
- void initReg() {
- reg[0x00] = 0b00010001;
- reg[0x01] = 0b00110001;
- reg[0x02] = (reg[0x02] & 0b00111111) | (0b11000000);
- reg[0x05] = 0b11111111;
- reg[0x06] = 0b01111111;
- reg[0x09] = (reg[0x09] & 0b01100000) | (0b10000101);
- //reg[0x0A]=(reg[0x0A]&0b00000011)|(0b11000000);
- reg[0x0B] = (reg[0x0B] & 0b11110000) | (0b00001101);
- reg[0x0C] = 0b00100011;
- Wire.beginTransmission(SC8815_ADDR);
- Wire.write(0x00);
- for (int i = 0; i <= 0x0C; i++) {
- Wire.write(reg[i]);
- }
- Wire.endTransmission();
- }
- void setup() {
- // put your setup code here, to run once:
- pinMode(14, OUTPUT);
- digitalWrite(14, HIGH); // PSTOP HIGH
- pinMode(12, OUTPUT);
- digitalWrite(12, LOW); // CHIP enabled
- delay(5000);
- Wire.begin();
- Serial.begin(115200);
- readReg();
- initReg();
- pinMode(26, OUTPUT);
- digitalWrite(26, HIGH); // turn on PORTFET
- pinMode(27, INPUT);
- digitalWrite(14, LOW); //PSTOP LOW
- }
- void loop() {
- // put your main code here, to run repeatedly:
- while (1) {
- readReg();
- int oriVBUS = (((((int)reg[0x0D]) << 8) | ((int)reg[0x0E])) >> 6) + 1;
- int oriVBAT = (((((int)reg[0x0F]) << 8) | ((int)reg[0x10])) >> 6) + 1;
- int oriIBUS = (((((int)reg[0x11]) << 8) | ((int)reg[0x12])) >> 6) + 1;
- int oriIBAT = (((((int)reg[0x13]) << 8) | ((int)reg[0x14])) >> 6) + 1;
- Serial.println("---------------------------------------------------------");
- Serial.print("VBUS=");
- Serial.print((float)oriVBUS * 12.5 * 0.002);
- Serial.println("V.");
- Serial.print("VBAT=");
- Serial.print((float)oriVBAT * 12.5 * 0.002);
- Serial.println("V.");
- Serial.print("IBUS=");
- Serial.print((float)oriIBUS / 200);
- Serial.println("A.");
- Serial.print("IBAT=");
- Serial.print((float)oriVBUS / 50);
- Serial.println("A.");
- Serial.print("STATUS=");
- Serial.println(reg[0x17], BIN);
- Serial.println();
- delay(1000);
- }
- }
复制代码 |
|