dbuezas / lgt8fx

Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
369 stars 88 forks source link

can not compile code #124

Closed smarta1980 closed 1 year ago

smarta1980 commented 3 years ago

I am using emonlib.h with lgt8f328 using arduino ide but can not compile code

C:\Users\hitro\Documents\Arduino\hardware\lgt8fx-master\lgt8f\cores\lgt8f/lgtx8p.h:590:17: error: expected unqualified-id before 'volatile'

define VCAL _SFR_MEM8(0xC8)

             ^

could you please tell me what is the problem?

LaZsolt commented 3 years ago

The problem is emonlib.h contain this line (number 74) double VCAL;

This variabe name same as the LGT8F328P's reference voltage calibration register's name. You must rename every reference of VCAL variable in emonlib.h and emonlib.cpp.

LaZsolt commented 3 years ago

Another thing. You must modify readVcc(), because ADC accessing the different way of 3 reference voltages than ATmega, ADC value is 12 bit wide, ADC has gain error which has to be compensated and READVCC_CALIBRATION_CONST must be recalculated. (LGT8F328P reference voltages: 1.024 V, 2.048 V and 4.096 V)

My readVcc modification may help you: https://github.com/dbuezas/lgt8fx/discussions/123#discussion-3287695

dwillmore commented 1 year ago

This appears to be a user library error. Closing. Please reopen if a change to this library is needed.