I need the temperature information from the TEMPERATURE INDICATOR MODULE of a PIC16F15325. Unfortunately there seems to be no routine in the GCB for this PIC.
I managed to read out a value with this code snippet, which changes with the temperature:
FVRCON=b'11110010''bit 7 FVREN: Fixed Voltage Reference is enabled 'bit6FVRRDY:FixedVoltageReferenceoutputisreadyforuse'bit 5 TSEN: Temperature Indicator is enabled 'bit4TSRNG:TemperatureinHighRange'bit 3-2 CDAFVR<1:0>: Comparator FVR Buffer is off 'bit1-0ADFVR<1:0>:ADCFVRBufferGainis2x,(2.048V)ADCON1=b'11110011''bit 7 ADFM: ADC Result Format Select bit 'bit6-4ADCS<2:0>:ADCConversionClockSelectbits'bit 3-2 Unimplemented 'bit1-0ADPREF<1:0>:ADCPositiveVoltageReferenceConfigurationbitsADACT=0x0E'bit 3-0 ADACT<3:0>: Auto-Conversion Trigger Selection bits => Interrupt-on change flag triggerWait 50 us 'TimeforADCswitchingonDoADCON0=b'11110011''bit 7-2 ADCON0: Temperature sensor output 'bit1GO/DONE#:ADCConversionStatusbit=>startmeasurement'bit 0 ADON: ADC Enable bit => activate ADC Do loop Until ADCON0.1=0 'WartenbisGO/DONE#(Bit1)Lowwird=>measurementreadyWait20msSerPrint1,TemperHSerPrint1," # "SerPrint1,TemperLSerSend1,13,10'"Carriage Return/Line Feed"Loop
My problem is that I do not know how to read the calibration values from the DEVICE INFORMATION AREA to convert these numerical values into temperature values.
TABLE 6-1: DEVICE INFORMATION AREA==================================
8112h TSLR1 Unassigned (1 word)
8113h TSLR2 Temperature indicator ADC reading at 90°C (low range setting)
8114h TSLR3 Unassigned (1 word)
8115h TSHR1 Unassigned (1 word)
8116h TSHR2 Temperature indicator ADC reading at 90°C (high range setting)
8117h TSHR3 Unassigned (1 Word)
Can anyone help me with this???
THANKS!!!
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This system.h has a new method deviceconfigurationRead()
deviceconfigurationRead (location, store)
Available on all Microchip PIC microcontrollers. Used for reading NON-PFM memory
Explanation:
deviceconfigurationRead reads information from the memory on chip that is not part of the program memory. location and store are both word variables, meaning that they can store values over 255.
This is an advanced command which should only be used by advanced developers. Refer to the datasheet for explicit data to be read.
''' This demonstration is for Great Cow BASIC'''''' This demonstration how you read the DIA section of the chip.''''''************************************************************************'''''' PIC: 16F18855'''Compiler:GCB''' IDE: GCB@SYN'''''' Board: Xpress Evaluation Board''''''''''''@author EvanV'''@licenceGPL'''@version 1.00'''@date30/04/2023'''***'-----Configuration'Chip Settings.#CHIP 16f18855,32'GeneratedbyPICPPSToolforGreatCowBasic'PPS Tool version: 0.0.5.5'PinManagerdata:07/03/2017''Templatecommentatthestartoftheconfigfile'#STARTUP InitPPS, 85Sub InitPPS 'Module:EUSART'TX > RC0 RC0PPS = 0x0010 'RC0>TX(bi-directional)TXPPS=0x0010EndSub'Template comment at the end of the config file'-----Constants#DEFINEUSART_BAUD_RATE19200#DEFINEUSART_TX_BLOCKING#DEFINELEDD2PORTA.0#DEFINELEDD3PORTA.1#DEFINELEDD4PORTA.2#DEFINELEDD5PORTA.3DirLEDD2OutDirLEDD3OutDirLEDD4OutDirLEDD5Out#DEFINEPotentiometerPORTA.4DirPotentiometerIn#DEFINESWITCH_DOWN0#DEFINESWITCH_UP1#DEFINESWITCHPORTA.5DirSWITCHIn' ----- Variables'NoVariablesspecifiedinthisexample.Allbytevariablesaredefineduponuse.' ----- Quick Command Reference:'[todo]'-----Mainbodyofprogramcommenceshere.HSerPrintCRLFHSerPrintChipNameStr+" Great Cow BASIC Demo"HSerPrintCRLFWait3sIfTrim("16F18855")<>ChipNameStrThenHSerPrint"Wrong Microcontroller program intended for 16F18855"HSerPrintCRLFElseDIMtshr2ASWordHSerPrint"0x8006: "deviceconfigurationRead(0x8006,tshr2)HSerPrint"0x"+hex(tshr2_h)HSerPrinthex(tshr2)HSerPrintCRLFEndIfWaitWhileTRUE
The program above shows the DeviceID on the terminal.
Hi Anobium,
my proposal für the method's name is: DeviceConfigRead().
I'm new to PIC and Cow BASIC and wanted to learn how the configuration space is addressed.
So I looked into the latest system.h and compared the functions ProgramRead() and deviceconfigurationRead() but I could not find any differences.
I thought, that to address the config space I should activate the bit NVMREGS in NVMCON1. What did I overlook?
Thank you in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the attached file look at line 4098. This sets NVMREGS . How? The compiler knows that certain register.bit have the different name for the same register location. So, CFGS equates to NVMREGS.
The ASM shows the proof. Where Set CFGS ON is transformed into bsf NVMCON1,NVMREGS
;Set CFGS ON
bsf NVMCON1,NVMREGS
The compiler directive that supports this is #SAMEBIT (there is also #SAMEVAR). If you use GCODE IDE to search all the libraries you will find where #SameBit NVMREGS, CFGS is defined.
Hi Evan,
your new "system.h" doesn't work for me. When I replace the previous one with the new one, my serial output doesn't work anymore (only garbage comes), even if I don't call ProgramRead at all...
My current version is the 0.99.010 - is that ok?
My read out DIA values (with old "system.h") were apparently really wrong! I had read out these values with ProgramRead: TSHR1=5822, TSHR2=5715, TSHR3=334
WITHOUT calling ProgramRead (so just outputting the variables) I get: TSHR1=4, TSHR2=5822 TSHR3=5715
It looks like these are just any values...
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I could add a prerequisite check to the compiler. But, this would only work on stuff going forward ( changes in the future ). So, it would be pointless.
The general rule. Keep the toolchain and libraries at a consistent release level.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need the temperature information from the TEMPERATURE INDICATOR MODULE of a PIC16F15325. Unfortunately there seems to be no routine in the GCB for this PIC.
I managed to read out a value with this code snippet, which changes with the temperature:
My problem is that I do not know how to read the calibration values from the DEVICE INFORMATION AREA to convert these numerical values into temperature values.
Can anyone help me with this???
THANKS!!!
Frank
To read the value of the memory use ProgramRead ( ProgMemAddress, DataWord )
Thanks! I will try it! (I did not know this command yet...)
Frank
It would be nice to see a working example
of ProgramRead(). There are many in the demos. If using GCCode select the Demo folder using 'Open Folder' and do a search using 'in files'.
Last edit: Anobium 2023-04-14
Thanks
After I read out only strange values from the DIA, I would like to ask if I am doing it right at all:
DIM TSHR2 AS Word
ProgramRead(0x8116,TSHR2)
When I try to read the DeviceID at 8006h, I don't get the appropriate value back either:
ProgramRead(0x8006,DeviceID)
I read as DeviceID 873h from address 8006h....
What am I doing wrong???
THANKS!!!
Frank
An updated system.h.
This system.h has a new method deviceconfigurationRead()
deviceconfigurationRead (location, store)
Available on all Microchip PIC microcontrollers. Used for reading NON-PFM memory
Explanation:
deviceconfigurationRead reads information from the memory on chip that is not part of the program memory.
location
andstore
are both word variables, meaning that they can store values over 255.This is an advanced command which should only be used by advanced developers. Refer to the datasheet for explicit data to be read.
The program above shows the DeviceID on the terminal.
Last edit: Anobium 2023-04-30
If you can think of a better name for the method, rather than deviceconfigurationRead () then please let me know before I write the Help!
Hi Anobium,
my proposal für the method's name is: DeviceConfigRead().
I'm new to PIC and Cow BASIC and wanted to learn how the configuration space is addressed.
So I looked into the latest system.h and compared the functions ProgramRead() and deviceconfigurationRead() but I could not find any differences.
I thought, that to address the config space I should activate the bit NVMREGS in NVMCON1. What did I overlook?
Thank you in advance!
We will use DeviceConfigRead() - thank you.
In the attached file look at line 4098. This sets NVMREGS . How? The compiler knows that certain register.bit have the different name for the same register location. So, CFGS equates to NVMREGS.
The ASM shows the proof. Where
Set CFGS ON
is transformed intobsf NVMCON1,NVMREGS
The compiler directive that supports this is #SAMEBIT (there is also #SAMEVAR). If you use GCODE IDE to search all the libraries you will find where
#SameBit NVMREGS, CFGS
is defined.Hi Evan,
your new "system.h" doesn't work for me. When I replace the previous one with the new one, my serial output doesn't work anymore (only garbage comes), even if I don't call ProgramRead at all...
My current version is the 0.99.010 - is that ok?
My read out DIA values (with old "system.h") were apparently really wrong! I had read out these values with ProgramRead: TSHR1=5822, TSHR2=5715, TSHR3=334
WITHOUT calling ProgramRead (so just outputting the variables) I get: TSHR1=4, TSHR2=5822 TSHR3=5715
It looks like these are just any values...
Frank
The system.h will only work wits 1.xx.xx compiler.
There are many dependencies across the libs.
The old ProgramRead reads the ProgMem only.
I could add a prerequisite check to the compiler. But, this would only work on stuff going forward ( changes in the future ). So, it would be pointless.
The general rule. Keep the toolchain and libraries at a consistent release level.
Added deviceconfigurationRead() to read Device Configuration ( additive to ProgramRead as ProgramRead limited to PFM )
Help updated with new method.
Now included in build 1242
Update should be live at 05:00 UTC or earlier.
THANK YOU!