i have adapted one of the demo coes for the microchip PICDEM2 plus 2010 (in the vendor boards folder)
the first call is for a temperature display followed by voltmeter and clock.the volts and time routines both work;
but somehow it seems like the temperature call doesn't work as the display goes blank.it's got me baffled.
yes thats the board i'm using; i tried to post the PDF dated 2004 revB,but this forum software doesn't like PDF as an extension...delivery failed due to a security concern.
i've checked the manual (both ones!) and the schematic is identical for both years and revisions
the pinouts are here:-
I assume the board is OK.
And, I know that this is a very old chip.
Therefore, I looked as the ASM generated by your program.
It has the following - meaning a RAM variable called SSPCON2 has been created by the HWI2C library. This means the library has not been tested with that chip. The library expects the SSPCON2 I2C register, as this does not exist... it creates a byte variable.
SSPCON2 EQU 62 ; 0x3E (SA)
Next, open PICINFO to access the Datasheet.
Page 212. 19.3 SSP I2C Operation
The SSP module, in I2C mode, fully implements all slave functions except general call support and provides interrupts on Start and Stop bits in hardware to facilitate firmware implementations of the master functions. The SSP module implements the standard mode specifications, as well as 7-bit and 10-bit addressing.
So, this is a slave only I2C implementation.
So, changing the program to software I2C and it with work OK as a MASTER device. Change the I2C Discovery program ( I would use an existing Software i2C discovery program and just change the chip etc. Then, change the other program. I2C discovery is always a pre-req).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please also try this. Add the following to HWI2C.h, in the #script section of the library.
This will inspect 18F chips, ensure SSP2CON2 exists and checks for HI2C_DATA. If this failes the compiler will issue a warning.
//Check for SLAVE only 18F chipIfChipSubFamily=16000ThenIfNOVAR(SSPCON2)ThenIfDEF(HI2C_DATA)Then// So, this is an 18F chip, has not got SSP2CON2 and the user has defined HI2C_DATAError"Microcontroller does not support hardware I2C, please use software I2C."EndIfEndIfEndIf
I have changed from ChipFamily = 16 to ChipSubFamily = 16000. ChipSubFamily = 16000 are the older chips.
I have added this to the master build here, run all the tests and this seems to work OK. Should trap and issue a message when appropriate.
Last edit: Anobium 2025-03-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IT LIVES! i finally got the code to do what it was meant to do.Here are the files for the 'demo' folder
I've included the assembly file to put the code 'under the microscope'
at the moment i'm trying to cover the gaps i left in the 16F76 examples,due to running out of pins etc. so its demo's 14 15 & 16 (the I2C eeprom routines) from the demonstration example for the early board version.i also have to sidestep the code with PPS used...watch this space!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is my reference file:-
C:\GCstudio\gcbasic\demos\Vendor_Boards\Microchip_PICDEM_2_plus_board_2006
i unpicked the eeprom code from the multiple demo's contained in the one 'capability' program!
hence the 'orphaned' bits throwing errors...but now i'm down to three errors with,i believe, 2 root causes;getting there slowly!
Open the LST file produced. Search for the last hex number in the error message - 00390 This will show the error source. In this case 000390 1500 ANDWF 4PORT, W,BANKED. This confirms the source.
OK now i've followed your instructions,and found out how to enable basic code in the assembly listing; i eventually figured out it should be just :-
' SW2 ' and Not ' SW2 PORT ' a silly mistake; as SW2's PORT was already defined! The code now produces a hex file....BUT it doesn't seem to run!
EDIT it is writing to an external eeprom? so i can't check the contents using PK2..hmmm how would i go about this?
Check i2CDiscovery with a full power cycle the board.
Remove the eeprom_wr_array and eeprom_rd_array function. Do you get action on the display? Work back until you get the display working. What is serial debug showing?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i have adapted one of the demo coes for the microchip PICDEM2 plus 2010 (in the vendor boards folder)
the first call is for a temperature display followed by voltmeter and clock.the volts and time routines both work;
but somehow it seems like the temperature call doesn't work as the display goes blank.it's got me baffled.
I would isolate this issue.
As you have noted that ShowI2CTemperature() does not operate as expected.
So, take that routine and change as below:
If this shows 20c on the LCD then you know the issue is in the I2C interface.
Have you tried I2CDiscovery to ensure the I2C address is correct?
Is the
I2CTEMPSENSOR 0x9A
found?i've made a version of I2C discovery for this chip/board and the results are these:-
it seems neither the temperature sensor nor the eeprom are found (they share a bus)
Last edit: HackInBlack 2025-03-09
Which board are you using?
The PICDEM2 plus c2002 with a PIC18F4431
Is this your board ? https://github.com/GreatCowBASIC/Demonstration_Sources/tree/main/Vendor_Boards/Microchip_PICDEM%202%20plus_board_2002
If not, what is the URL to your Board? I need the circuit diagram.
yes thats the board i'm using; i tried to post the PDF dated 2004 revB,but this forum software doesn't like PDF as an extension...delivery failed due to a security concern.
i've checked the manual (both ones!) and the schematic is identical for both years and revisions
the pinouts are here:-
I assume the board is OK.
And, I know that this is a very old chip.
Therefore, I looked as the ASM generated by your program.
It has the following - meaning a RAM variable called SSPCON2 has been created by the HWI2C library. This means the library has not been tested with that chip. The library expects the
SSPCON2
I2C register, as this does not exist... it creates a byte variable.SSPCON2 EQU 62 ; 0x3E (SA)
Next, open PICINFO to access the Datasheet.
So, this is a slave only I2C implementation.
So, changing the program to software I2C and it with work OK as a MASTER device. Change the I2C Discovery program ( I would use an existing Software i2C discovery program and just change the chip etc. Then, change the other program. I2C discovery is always a pre-req).
Please also try this. Add the following to HWI2C.h, in the #script section of the library.
This will inspect 18F chips, ensure SSP2CON2 exists and checks for HI2C_DATA. If this failes the compiler will issue a warning.
I have changed from ChipFamily = 16 to ChipSubFamily = 16000. ChipSubFamily = 16000 are the older chips.
I have added this to the master build here, run all the tests and this seems to work OK. Should trap and issue a message when appropriate.
Last edit: Anobium 2025-03-12
IT LIVES! i finally got the code to do what it was meant to do.Here are the files for the 'demo' folder
I've included the assembly file to put the code 'under the microscope'
Last edit: HackInBlack 2025-03-12
Excellent.
We have improved the I2C library which is a good thing.
Will you be posting a complete suite of demos? including I2C discovery?
i'll try 80) here's the discovery one .
Thanks. Great work
Will you be publishing a suite that I can put in the demo folder?
at the moment i'm trying to cover the gaps i left in the 16F76 examples,due to running out of pins etc. so its demo's 14 15 & 16 (the I2C eeprom routines) from the demonstration example for the early board version.i also have to sidestep the code with PPS used...watch this space!
here's demo 14 with three errors,which i think reference other parts of the original code...not sure where they are yet!
Here goes.
I took these from .. Demos\Vendor_Boards\Microchip_Explorer_8_Demo_Board\PIC18F\18F67K40_Explorer8_Capability_demo.gcb
What was your source GCB? Did you purge these pieces out?
This is my reference file:-
C:\GCstudio\gcbasic\demos\Vendor_Boards\Microchip_PICDEM_2_plus_board_2006
i unpicked the eeprom code from the multiple demo's contained in the one 'capability' program!
hence the 'orphaned' bits throwing errors...but now i'm down to three errors with,i believe, 2 root causes;getting there slowly!
Last edit: HackInBlack 2025-03-12
here's the errors:-
new version with 2 GCASM errors that have me stumped
Last edit: HackInBlack 2025-03-12
Both caused by typos in the source program, specifically
SW2 PORT
To resolve this sort of issue. Here is my method for the following:
000390 1500 ANDWF 4PORT, W,BANKED
. This confirms the source.4PORT
.Last edit: Anobium 2025-03-13
OK now i've followed your instructions,and found out how to enable basic code in the assembly listing; i eventually figured out it should be just :-
' SW2 ' and Not ' SW2 PORT ' a silly mistake; as SW2's PORT was already defined! The code now produces a hex file....BUT it doesn't seem to run!
EDIT it is writing to an external eeprom? so i can't check the contents using PK2..hmmm how would i go about this?
Last edit: HackInBlack 2025-03-13
:-) That is good re compiling. However, do you get any thing displayed ?
yippee i get results in PUTTY
nope
Last edit: HackInBlack 2025-03-13
Check i2CDiscovery with a full power cycle the board.
Remove the eeprom_wr_array and eeprom_rd_array function. Do you get action on the display? Work back until you get the display working. What is serial debug showing?
with rd and wr remmed out putty shows this:-
I2C EEPROM
Initial Array
-:1,2,3,4,5,6,7,8,9,10
LCD is still blank after power cycling the board
Last edit: HackInBlack 2025-03-13