Menu

Resolved: temperature not displaying in demo code

Help
2025-03-07
2025-03-14
1 2 > >> (Page 1 of 2)
  • HackInBlack

    HackInBlack - 2025-03-07

    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.

     
  • Anobium

    Anobium - 2025-03-08

    I would isolate this issue.

    As you have noted that ShowI2CTemperature() does not operate as expected.

    So, take that routine and change as below:

    Sub ShowI2CTemperature
    
        InitLCDChar
    
      // Set temperatureVal - set to 20 as a test
    
            temperatureVal = 20
            Locate 0,12
            Print temperatureVal
            LCDWriteChar 0
            Print "C "
    
    End Sub     // GCBASIC Program.
    

    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?

     
  • HackInBlack

    HackInBlack - 2025-03-09

    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
  • Anobium

    Anobium - 2025-03-09

    Which board are you using?

     
  • HackInBlack

    HackInBlack - 2025-03-10

    The PICDEM2 plus c2002 with a PIC18F4431

     
  • HackInBlack

    HackInBlack - 2025-03-11

    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:-

     
  • Anobium

    Anobium - 2025-03-12

    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).

     
  • Anobium

    Anobium - 2025-03-12

    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 chip
      If ChipSubFamily = 16000 Then
        If NOVAR(SSPCON2) Then
          If DEF(HI2C_DATA) Then
            // So, this is an 18F chip, has not got SSP2CON2 and the user has defined HI2C_DATA
            Error "Microcontroller does not support hardware I2C, please use software I2C."
          End If 
        End If 
      End If
    

    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
  • HackInBlack

    HackInBlack - 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
  • Anobium

    Anobium - 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?

     
  • HackInBlack

    HackInBlack - 2025-03-12

    i'll try 80) here's the discovery one .

     
  • Anobium

    Anobium - 2025-03-12

    Thanks. Great work

    Will you be publishing a suite that I can put in the demo folder?

     
  • HackInBlack

    HackInBlack - 2025-03-12

    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!

     
  • HackInBlack

    HackInBlack - 2025-03-12

    here's demo 14 with three errors,which i think reference other parts of the original code...not sure where they are yet!

     
    • Anobium

      Anobium - 2025-03-12

      Here goes.

          // Common macro and constants
              #define LEDS_OFF            LED_D8=0:LED_D7=0:LED_D6=0:LED_D5=0:LED_D4=0:LED_D3=0:LED_D2=0:LED_D1=0
      
          // Variable Definitions
              Dim labNumber as Byte:          labNumber   = 0               
              Dim switchEvent as Byte:        switchEvent = 0
      
      Sub checkButtonS2
      
          if btnState = NOT_PRESSED Then
              if SWITCH_S2_PORT = 0 Then  
                  wait 100 ms
                  btnState = PRESSED
              end If
          else if SWITCH_S2_PORT = 1 Then
                  btnState = NOT_PRESSED
                  switchEvent = 1                                                   
          end if
      
      End Sub
      

      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?

       
  • HackInBlack

    HackInBlack - 2025-03-12

    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
  • HackInBlack

    HackInBlack - 2025-03-12

    here's the errors:-

     
  • HackInBlack

    HackInBlack - 2025-03-12

    new version with 2 GCASM errors that have me stumped

     

    Last edit: HackInBlack 2025-03-12
  • Anobium

    Anobium - 2025-03-13

    Both caused by typos in the source program, specifically SW2 PORT

    To resolve this sort of issue. Here is my method for the following:

    Error: Variable 4PORT was not explicitly declared
     Error: GCASM: Symbol [SFR]4PORT has not been defined. Inspect ASM file to determine error  at `ANDWF 4PORT, W,BANKED` Hexfile address(see lst file): 000390
     Error: GCASM: Symbol [SFR]4PORT has not been defined. Inspect ASM file to determine error  at `ANDWF 4PORT, W,BANKED` Hexfile address(see lst file): 0003AC
    
    1. Ensure GCBASIC source code is shown in ASM.
    2. 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.
    3. Open the ASM, search for 4PORT.
    4. Examine the GCBASIC source for error
    5. Correct error.

     

    Last edit: Anobium 2025-03-13
  • HackInBlack

    HackInBlack - 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
    • Anobium

      Anobium - 2025-03-13

      :-) That is good re compiling. However, do you get any thing displayed ?

       
  • HackInBlack

    HackInBlack - 2025-03-13

    yippee i get results in PUTTY


    nope

     

    Last edit: HackInBlack 2025-03-13
  • Anobium

    Anobium - 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?

     
  • HackInBlack

    HackInBlack - 2025-03-13

    with rd and wr remmed out putty shows this:-

    I2C EEPROM
    Initial Array
    -:1,2,3,4,5,6,7,8,9,10

    Repopulate Array with #127 to ensure the EEPROM results are read correctly
        -:127,127,127,127,127,127,127,127,127,127
    
    Read Array from EEProm results
        -:127,127,127,127,127,127,127,127,127,127
    
    End of array operations
    

    LCD is still blank after power cycling the board

     

    Last edit: HackInBlack 2025-03-13
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.