Go to last post By: AlbertoFS
Today 17:21
Forum: Projects discussion
Starter: AlbertoFS
Views: 0
Replies: 7
Today 10:57
Forum: The Lounge
Starter: Les
Views: 0
Replies: 3
+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: HBUSIN stops program?11 days old

  1. #1
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    162
    Thumbs Up
    Received: 12
    Given: 1
    Total Downloaded
    256.57 MB

    0 Not allowed!

    Question HBUSIN stops program?

    Hi people.

    I've a problem with HBUSIN (HBUSOUT not tried yet)
    If I activate this command, then the program stops by this command.

    Code:
    DEVICE = 18F45K40
    
    
    CONFIG_START
    ' FEXTOSC   = HS              ;HS (crystal oscillator) above 8 MHz; PFM set to high power
    ' RSTOSC    = EXTOSC          ;EXTOSC, with EXTOSC operating per FEXTOSC bits   
      FEXTOSC   = OFF             ;Oscillator not enabled
      RSTOSC    = HFINTOSC_64MHZ  ;HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1  
    ' RSTOSC    = EXTOSC_4PLL     ;EXTOSC with 4x PLL, with EXTOSC operating per FEXTOSC bits  
      CLKOUTEN  = OFF             ;CLKOUT function is disabled
      CSWEN     = ON              ;Writing to NOSC and NDIV is allowed
      FCMEN     = OFF             ;Fail-Safe Clock Monitor disabled
      MCLRE     = INTMCLR         ;If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin function is MCLR
      PWRTE     = ON              ;Power up timer enabled
      LPBOREN   = OFF             ;ULPBOR disabled
      BOREN     = ON              ;Brown-out Reset enabled according to SBOREN
      BORV      = VBOR_245        ;Brown-out Reset Voltage (VBOR) set to 2.45V
      ZCD       = OFF             ;Zero Cross Detection disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
      PPS1WAY   = ON              ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle  
      STVREN    = ON              ;Stack full/underflow will cause Reset
      DEBUG     = OFF             ;Background debugger disabled
      XINST     = OFF             ;Extended Instruction Set and Indexed Addressing Mode disabled
      WDTCPS    = WDTCPS_31       ;Divider ratio 1:65536; software control of WDTPS
      WDTE      = OFF 'ON             ;WDT enabled regardless of sleep
      WDTCWS    = WDTCWS_7        ;Window always open (100%); software control; keyed access not required
      WDTCCS    = SC              ;Software Control
      WRT0      = OFF             ;Block 0 (000800-001FFFh) not write-protected
      WRT1      = OFF             ;Block 1 (002000-003FFFh) not write-protected
      WRT2      = OFF             ;Block 2 (004000-005FFFh) not write-protected
      WRT3      = OFF             ;Block 3 (006000-007FFFh) not write-protected
      WRTC      = OFF             ;Configuration registers (300000-30000Bh) not write-protected
      WRTB      = OFF             ;Boot Block (000000-0007FFh) not write-protected
      WRTD      = ON              ;Data EEPROM write-protected
      SCANE     = ON              ;Scanner module is available for use, SCANMD bit can control the module
      LVP       = OFF             ;Low voltage programming disabled.
      CP        = OFF             ;UserNVM code protection disabled
      CPD       = OFF             ;DataNVM code protection disabled
      EBTR0     = OFF             ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
      EBTR1     = OFF             ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
      EBTR2     = OFF             ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
      EBTR3     = OFF             ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
      EBTRB     = OFF             ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    CONFIG_END
    
    
    
    
    DECLARE ALL_DIGITAL = TRUE
    DECLARE XTAL        = 64      ;64MHz internal oscillator
    DECLARE HSCL_PIN    = PORTC.3 ;PPS (Peripheral Pin Select) voor HBUSIN/HBUSOUT (clock)
    DECLARE HSDA_PIN    = PORTC.4 ;PPS (Peripheral Pin Select) voor HBUSIN/HBUSOUT (data)
                       
    DECLARE LCD_ENPIN   = PORTD.2 ;\
    DECLARE LCD_RSPIN   = PORTD.3 ;- Tijdelijk LC-Display
    DECLARE LCD_DTPIN   = PORTD.4 ;/
    
    
    
    
    ;Include files
    INCLUDE "c:\PIC programmas\PPS_18FxxK40.inc"   ;Bevat de assembler routines voor instellen van de Peripheral Pin Selection (PPS)
    
    
    ;IC ID-slave adresnamen (Externe EEPROM)
    SYMBOL EE24C512r  = %10100001 ;ID-slave adres om 24C512 uit te lezen (r = read)
    SYMBOL EE24C512w  = %10100000 ;ID-slave adres om naar 24C512 te schrijven (w = write)
    
    
    SYMBOL SCL        = PORTC.3   ;Q: IC Serial ClocK - voor o.a. de externe EEPROM met machine-instellingen
    SYMBOL SDA        = PORTC.4   ;I: IC Serial DatA  - voor o.a. de externe EEPROM met machine-instellingen
    
    
    
    
    ;Variabelen declareren (alfabetische volgorde)
    DIM Var1    AS WORD
    DIM Var2    AS WORD
    
    
    CLEAR                         ;Wis RAM geheugen
    
    
    DELAYMS 150                   ;Signaal stabilisering
    
    
    CLS
    PRINT @Var1                   ;Display test
    DELAYMS 1000
    
    
    GOTO InitialiseerPPS
    
    
    
    
    
    
    ;======= MAIN PROGRAM ========
    Main:
    
    
    Var1 = 100
    PRINT AT 1, 1, @Var1, "< "
    
    
    Var2 = HBUSIN EE24C512r, 256  ;HBUSIN manner 1
    'HBUSIN Var2                  ;HBUSIN manner 2
    'HBUSIN EE24C512r, 256, [Var1];HBUSIN manner 3
     
    WHILE
      PRINT AT 1, 1, @Var1, "< "
      PRINT AT 2, 1, @Var2, "< "
      DELAYMS 250
      INC Var1
    WEND
    
    
    
    
    
    
    ;======= INITIALISEREN ======= Voor voorbeelden hierover, open het "PPS_18FxxK40.inc" bestand (met bijvoorbeeld Proton of kladblok) en scroll helemaal naar onder
    InitialiseerPPS:              ;PPS (Peripheral Pin Selection) PIC pin toeverwijzing
    '  iPPSInput (cIn_Fn_RX1DT1, cIn_Pin_RC7)    ;RX1 to RC7 input, USB ontvangst kanaal, data afkomstig van het bedieningspaneel komt op pin PORTC.7 binnen
    '  iPPSOutput(cOut_Pin_RC6,  cOut_Fn_TX1CK1) ;RC6 output from TX1, USB zend kanaal, data dat naar het bedieningspaneel verzonden moet worden wordt op pin PORTC.6 aangeboden
    
    
    '  iPPSInput (cIn_Fn_MSSP1DAT, cIn_Pin_RC4)
      iPPSOutput(cOut_Pin_RC4,  cOut_Fn_SDO1) 
      iPPSOutput(cOut_Pin_RC3,  cOut_Fn_SCK1)   ;SCK1/SCL1 clock output voor IC
    GOTO Main                     ;Start nu met het hoofdprogramma
    Problem is, in the example program above, the program stops at the point where HBUSIN is located, and I don't know why...
    Maybe I've something wrong with the settings from PPS or maybe there is something wrong by PPS.
    I don't know, I'm busy with it a half day but I've got stuck.

    (Device: 18F45K40 / Compiler: V3.6.1.7)

    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

  2. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,547
    Thumbs Up
    Received: 59
    Given: 88
    Total Downloaded
    895.24 MB

    0 Not allowed!

    Default Re: HBUSIN stops program?

    Hbusin is a hardware command that has to wait until the flag says there is data in the register. So if no data is sent then I will wait. Just like HRSIN

    Look to see if there is a timeout for that command. Or you can look for the flag yourself, if it's set then run the Hbusin code to collect the data.

    Personally I use interrupt code and let it all run in the background.
    Tim

  3. #3
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,193
    Thumbs Up
    Received: 70
    Given: 37
    Total Downloaded
    2.68 GB

    0 Not allowed!

    Default Re: HBUSIN stops program?

    Frizie

    The two HBSIN commands are commented out, but I guess that's not the problem.

    Charlie
    Last edited by charliecoultas; 7th September 2018 at 19:34.

  4. #4
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    162
    Thumbs Up
    Received: 12
    Given: 1
    Total Downloaded
    256.57 MB

    0 Not allowed!

    Arrow Re: HBUSIN stops program?

    Thanx Tim.

    I didn't knew that, so now I can look further.
    Then I guess there is still something wrong with the PPS settings, because on an old 18F452 the same routine with the same external 24C512 EEPROM runs fine for many years.

    To be continued.


    @Charlie.
    I know the other two HBUSIN lines are commented out.
    But that's because I've tested more variations of the HBUSIN command.

    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

  5. #5
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    2,992
    Thumbs Up
    Received: 299
    Given: 109
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: HBUSIN stops program?

    Also remember, there is no real benefit in using the Hbus commands, and I truly wish I had not placed them into the compiler, because the of the mess Microchip have made of their peripherals over the years.

    You are better off using the I2Cout/I2CIn commands or the Bus commands.

    I'll take a look at the commands as soon as possible.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  6. #6
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,547
    Thumbs Up
    Received: 59
    Given: 88
    Total Downloaded
    895.24 MB

    0 Not allowed!

    Default Re: HBUSIN stops program?

    Opps

    I did not do my checking. Hbus in an i2c command not SPI

    I was talking about SPI

    Sorry!
    Tim

  7. #7
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    162
    Thumbs Up
    Received: 12
    Given: 1
    Total Downloaded
    256.57 MB

    0 Not allowed!

    Exclamation Re: HBUSIN stops program?

    Hi Les.

    Today I'm working further on my PIC program to get the I2C EEPROM working together with the PPS, but I found another anomaly.
    I get an assembler error when I activate DECLARE HSERIN2_PIN = PORTC.4 (because I'm busy to test other PPS functions)
    Assembler error message: _PPS_FN_RX2 not found.
    (18F45K40)

    I2CIN en I2COUT no succes so far, but lucky they don't stop the program as HBUSIN does.

    Frizie.
    Last edited by Frizie; 13th September 2018 at 11:42. Reason: PIC device forgotten)
    Ohm sweet Ohm: www.picbasic.nl

  8. #8
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    162
    Thumbs Up
    Received: 12
    Given: 1
    Total Downloaded
    256.57 MB

    0 Not allowed!

    Red face Re: HBUSIN stops program?

    Succes!
    Bt with I2IN / I2COUT on the standard ports (PORTC.3 SCL / PORTC.4 SDA)
    And I shouldn't declare the PPS even if it's the standard PORTs (as I did in the examples in this topic, I don't know why I did that .


    For those who gonna use the 24C512 (or other type EEPROM from this serie like 24C32, 24C256)

    Code:
    'Compiler versie V3.6.1.7
    
    
    DEVICE = 18F45K40
    
    
    CONFIG_START
    ' FEXTOSC   = HS              ;HS (crystal oscillator) above 8 MHz; PFM set to high power
    ' RSTOSC    = EXTOSC          ;EXTOSC, with EXTOSC operating per FEXTOSC bits   
      FEXTOSC   = OFF             ;Oscillator not enabled
      RSTOSC    = HFINTOSC_64MHZ  ;HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1  
    ' RSTOSC    = EXTOSC_4PLL     ;EXTOSC with 4x PLL, with EXTOSC operating per FEXTOSC bits  
      CLKOUTEN  = OFF             ;CLKOUT function is disabled
      CSWEN     = ON              ;Writing to NOSC and NDIV is allowed
      FCMEN     = OFF             ;Fail-Safe Clock Monitor disabled
      MCLRE     = INTMCLR         ;If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin function is MCLR
      PWRTE     = ON              ;Power up timer enabled
      LPBOREN   = OFF             ;ULPBOR disabled
      BOREN     = ON              ;Brown-out Reset enabled according to SBOREN
      BORV      = VBOR_245        ;Brown-out Reset Voltage (VBOR) set to 2.45V
      ZCD       = OFF             ;Zero Cross Detection disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
      PPS1WAY   = ON              ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle  
      STVREN    = ON              ;Stack full/underflow will cause Reset
      DEBUG     = OFF             ;Background debugger disabled
      XINST     = OFF             ;Extended Instruction Set and Indexed Addressing Mode disabled
      WDTCPS    = WDTCPS_31       ;Divider ratio 1:65536; software control of WDTPS
      WDTE      = OFF 'ON             ;WDT enabled regardless of sleep
      WDTCWS    = WDTCWS_7        ;Window always open (100%); software control; keyed access not required
      WDTCCS    = SC              ;Software Control
      WRT0      = OFF             ;Block 0 (000800-001FFFh) not write-protected
      WRT1      = OFF             ;Block 1 (002000-003FFFh) not write-protected
      WRT2      = OFF             ;Block 2 (004000-005FFFh) not write-protected
      WRT3      = OFF             ;Block 3 (006000-007FFFh) not write-protected
      WRTC      = OFF             ;Configuration registers (300000-30000Bh) not write-protected
      WRTB      = OFF             ;Boot Block (000000-0007FFh) not write-protected
      WRTD      = ON              ;Data EEPROM write-protected
      SCANE     = ON              ;Scanner module is available for use, SCANMD bit can control the module
      LVP       = OFF             ;Low voltage programming disabled.
      CP        = OFF             ;UserNVM code protection disabled
      CPD       = OFF             ;DataNVM code protection disabled
      EBTR0     = OFF             ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
      EBTR1     = OFF             ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
      EBTR2     = OFF             ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
      EBTR3     = OFF             ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
      EBTRB     = OFF             ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    CONFIG_END
    
    
    
    
    DECLARE ALL_DIGITAL  = TRUE
    DECLARE XTAL         = 64     ;64MHz internal oscillator
    DECLARE I2C_SLOW_BUS = ON
    DECLARE I2C_BUS_SCL  = ON     ;Geen pull-up op de print aanwezig voor de kloklijn (ook niet plaatsen!)
    
    
    
    
    DECLARE LCD_ENPIN PORTD.2     ;\
    DECLARE LCD_RSPIN PORTD.3     ;- Tijdelijk LC-Display
    DECLARE LCD_DTPIN PORTD.4     ;/
    
    
    
    
    
    
    SYMBOL SCL        = PORTC.3   ;Q: IC Serial ClocK - voor o.a. de externe 24C512 EEPROM
    SYMBOL SDA        = PORTC.4   ;I: IC Serial DatA  - voor o.a. de externe 24C512 EEPROM
    
    
    ;IC ID-slave adresnamen (Externe EEPROM)
    SYMBOL EE24C512r  = %10100001 ;ID-slave adres om 24C512 uit te lezen (r = read)
    SYMBOL EE24C512w  = %10100000 ;ID-slave adres om naar 24C512 te schrijven (w = write)
    
    
    
    
    DIM WD1 AS WORD               ;Word Dummy 1
    
    
    
    
    I2COUT SDA, SCL, EE24C512w, 256, [1234]  ;Write to EEPROM address 256 (the 24C512 must have a 16-bits address!)
    DELAYMS 1000
    I2CIN  SDA, SCL, EE24C512r, 256, [WD1]   ;Read the EEPROM
    CLS
    PRINT @WD1
    Regards,
    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

  9. #9
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,769
    Thumbs Up
    Received: 151
    Given: 152
    Total Downloaded
    2.96 GB

    0 Not allowed!

    Default Re: HBUSIN stops program?

    Also remember, there is no real benefit in using the Hbus commands, and I truly wish I had not placed them into the compiler, because the of the mess Microchip have made of their peripherals over the years.

    Les, in what way are the Hbus commands different than the alternatives?
    George

  10. #10
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    162
    Thumbs Up
    Received: 12
    Given: 1
    Total Downloaded
    256.57 MB

    0 Not allowed!

    Arrow Re: HBUSIN stops program?

    A benefit of the (software) commands I2CIN and I2COUT is that you can apply these to almost all port-pins.
    Incidentally, remember that there should be a short delay after I2COUT (= writing to) when using an external EEPROM (not mentioned in the example above), especially if you do multiple write jobs after eachother.

    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. CCP2 on B3 stops D0 and D1 on 18F46k22
    By amateurtje in forum Projects discussion
    Replies: 8
    Last Post: 26th May 2017, 19:14
  2. Serial out stops program from working
    By RGV250 in forum Proton 24
    Replies: 9
    Last Post: 14th May 2016, 15:16
  3. Program stops after a while on the same section
    By chudson in forum Proton Plus Compiler v3
    Replies: 16
    Last Post: 19th October 2010, 07:13
  4. 18F4525 HBUSIN HBUSOUT program hang
    By Jeffrey in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 15th July 2007, 17:40
  5. Easy HID stops working!
    By pdgnr in forum Mecanique - IDE
    Replies: 1
    Last Post: 11th March 2006, 12:22

Members who have read this thread since 11th September 2018, 02:32 : 47

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts