
Thread: HBUSIN stops program? – 167 days old
-
7th September 2018, 15:59 #1
0HBUSIN 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) ;I²C 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: I²C Serial ClocK - voor o.a. de externe EEPROM met machine-instellingen SYMBOL SDA = PORTC.4 ;I: I²C 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 I²C GOTO Main ;Start nu met het hoofdprogramma
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
-
7th September 2018, 19:23 #2
- Join Date
- Jan 2003
- Posts
- 7,597
- Total Downloaded
- 895.24 MB
Thumbs Up Received: 69
Given: 91
0Re: 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
-
7th September 2018, 19:24 #3
- Join Date
- Sep 2010
- Posts
- 1,251
- Total Downloaded
- 2.98 GB
Thumbs Up Received: 77
Given: 39
0Re: HBUSIN stops program?
Frizie
The two HBSIN commands are commented out, but I guess that's not the problem.
CharlieLast edited by charliecoultas; 7th September 2018 at 19:34.
-
8th September 2018, 10:57 #4
0Re: 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
-
8th September 2018, 11:04 #5
- Join Date
- Feb 2002
- Posts
- 3,126
- Total Downloaded
- 1.53 GB
Thumbs Up Received: 356
Given: 129
0Re: 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
-
8th September 2018, 12:04 #6
- Join Date
- Jan 2003
- Posts
- 7,597
- Total Downloaded
- 895.24 MB
Thumbs Up Received: 69
Given: 91
0Re: HBUSIN stops program?
Opps
I did not do my checking. Hbus in an i2c command not SPI
I was talking about SPI
Sorry!Tim
-
13th September 2018, 11:39 #7
0Re: 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
-
13th September 2018, 12:32 #8
0Re: HBUSIN stops program?
Succes!
Bút 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: I²C Serial ClocK - voor o.a. de externe 24C512 EEPROM SYMBOL SDA = PORTC.4 ;I: I²C Serial DatA - voor o.a. de externe 24C512 EEPROM ;I²C 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
Frizie.Ohm sweet Ohm: www.picbasic.nl
-
13th September 2018, 13:52 #9
- Join Date
- Mar 2012
- Posts
- 1,947
- Total Downloaded
- 3.30 GB
Thumbs Up Received: 183
Given: 166
0Re: 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.
-
14th September 2018, 13:10 #10
0Re: 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
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
CCP2 on B3 stops D0 and D1 on 18F46k22
By amateurtje in forum Projects discussionReplies: 8Last Post: 26th May 2017, 19:14 -
Serial out stops program from working
By RGV250 in forum Proton 24Replies: 9Last Post: 14th May 2016, 15:16 -
Program stops after a while on the same section
By chudson in forum Proton Plus Compiler v3Replies: 16Last Post: 19th October 2010, 07:13 -
18F4525 HBUSIN HBUSOUT program hang
By Jeffrey in forum Proton Plus Compiler v3Replies: 0Last Post: 15th July 2007, 17:40 -
Easy HID stops working!
By pdgnr in forum Mecanique - IDEReplies: 1Last Post: 11th March 2006, 13:22
Members who have read this thread since 20th February 2019, 23:49 : 0
Actions : (Set Date) (Clear Date)
You do not have permission to view the list of names.
Proton Compiler Updates
Full install of 8-bit Proton and Proton24 Download the full compiler...
1st January 1970, 01:00