I have MCP3422 ADC with PIC16LF18855 and TM1637 4X7 Segment module
when I compile and run the code all ok on terminal but blank TM module until I have commented out the #option explicit line then all working ok.
here is my code:
'-------------------------------------------
#chip 16f18855
'#option explicit
#config RSTOSC_HFINT32, MCLR_ON
; ----- Define Hardware settings for hwi2c
' Define I2C settings - CHANGE PORTS if required for your specific device.
#define hi2c_BAUD_RATE 100
#define hi2c_DATA PORTC.3
#define hi2c_CLOCK PORTC.4
'Initialise I2C Master
'I2C pins need to be input for SSP2 module
Dir hi2c_DATA in
Dir hi2c_CLOCK in
hi2cMode Master
; ----- Main body of program commences here.
' Now assumes Serial Terminal is operational
dim DeviceID as byte
Dim DISPLAYNEWLINE as Byte
Dim hByte as Byte
Dim lByte as Byte
Dim regVal as Byte
Dim result as Long
Dim rmder as Byte
Write4Dig (17, 16, 17, 16, 0) 'clear display
wait 20 ms
TMchar_Bright = 11
TMdec(9999)
wait 50 ms
DO
'Instantiate MCP3422 for new ADC conversionDO HI2CReStart HI2CSend ( 0xD0 )loop While HI2CAckPollState HI2CSend ( 0xAB )'channel2,gain=8,oneshotconversionHI2CStop' wait for conversion completion WAIT 150 ms'Read3bytesfromMCP3422first2bytesardtheAnalogvalueandthe3rdistheregistervalueDOHI2CReStartHI2CSend(0xD1)LOOPWhileHI2CAckPollStateHI2CReceivehByte,ACK' Analog conversion higher byte HI2CReceive lByte, ACK 'AnalogconversionlowerbyteHI2CReceiveregVal,NAK' MCP3422 register value to check the settingHI2CStop HSerPrint "Conversion result X8 : " HSerPrint Hex(hByte) HSerPrint Hex(lByte) HSerPrint " Register: " HSerPrint Hex(regVal) HSerPrintCRLF HSerPrintCRLF HSerPrintCRLFresult=0result = result+ [long]hByteresult = 256 * result + lByte result = 7812 * result+result/2 result = result /100000 HSerPrint "mOhm: " HSerPrint (result) TMdec(result,0) HSerPrintCRLF IF result > 2048 THEN result=9999 END IF IF result > 2048 THEN TMdec(9999) 'WriteChar(0,"O")'WriteChar (1 , "U") 'WriteChar(2,"F")'WriteChar(3,"L")HSerPrintCRLFHSerPrint"mOhm: Out of Range !"HSerPrintCRLFELSEHSerPrintCRLFHSerPrint"mOhm: "HSerPrint(result)HSerPrintCRLFTMdec(result,0)ENDIFHSerPrintCRLFHSerPrintCRLFHSerPrintCRLF
wait 2 s
Loop
'------------------------------------------
Any help appreciated
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I moved the #option Explicit line after the include <tm1637a.h> and solve the issue
Thanks for your support and Yes TM_Bright = nn (nn 8to 15) is the right brughtness setting
All the best</tm1637a.h>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have MCP3422 ADC with PIC16LF18855 and TM1637 4X7 Segment module
when I compile and run the code all ok on terminal but blank TM module until I have commented out the #option explicit line then all working ok.
here is my code:
'-------------------------------------------
#chip 16f18855
'#option explicit
#config RSTOSC_HFINT32, MCLR_ON
#startup InitPPS, 85
Sub InitPPS
UNLOCKPPS
'Module: EUSART
RC6PPS = 0x0010 'TX > RC6
RXPPS = 0x0017 'RC7 > RX
End sub
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
#define sync SYNC_TX1STA
; ----- Define Hardware settings for hwi2c
' Define I2C settings - CHANGE PORTS if required for your specific device.
#define hi2c_BAUD_RATE 100
#define hi2c_DATA PORTC.3
#define hi2c_CLOCK PORTC.4
'Initialise I2C Master
'I2C pins need to be input for SSP2 module
Dir hi2c_DATA in
Dir hi2c_CLOCK in
; ----- Main body of program commences here.
' Now assumes Serial Terminal is operational
dim DeviceID as byte
Dim DISPLAYNEWLINE as Byte
Dim hByte as Byte
Dim lByte as Byte
Dim regVal as Byte
Dim result as Long
Dim rmder as Byte
Write4Dig (17, 16, 17, 16, 0) 'clear display
wait 20 ms
TMchar_Bright = 11
TMdec(9999)
wait 50 ms
DO
wait 2 s
Loop
'------------------------------------------
Any help appreciated
Thanks
Post the first line in the ASM being created.
And, I would update to the latest https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/GCB_Installer-v0.98.07%20RC45.exe/download
As there is nothing called Write4Dig in the new release. It is called TMWrite4Dig
Yes it is a typo but after correcting it still need to comment out #option explicit to get it working.
Thanks
Did you update the software?
Yes I did same error
Thanks
I do not know that library but
TM_Bright = 11
may work for you.I moved the #option Explicit line after the include <tm1637a.h> and solve the issue
Thanks for your support and Yes TM_Bright = nn (nn 8to 15) is the right brughtness setting
All the best</tm1637a.h>