18F47K40 Port B issue


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: 18F47K40 Port B issue173 days old

  1. #1
    Member geoff_c's Avatar
    Join Date
    Oct 2002
    Posts
    187
    Thumbs Up
    Received: 1
    Given: 6
    Total Downloaded
    558.26 MB

    0 Not allowed!

    Default 18F47K40 Port B issue

    Im having a problem with Port B on the 18F47K40. This is the first time Ive used a micro with the PPS so im guessing i missed something simple. Port B doesn't work at above 10 Mhz, other ports are fine. Appreciate some help on what to try next. I tried mapping any peripheral inputs on Port B to another unused pin.

    thanks

    Code:
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    Device = 18F47K40
    Config_Start
      FEXTOSC = OFF ;Oscillator not enabled
      RSTOSC = HFINTOSC_64MHZ ;HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
      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 fuction is MCLR
      PWRTE = OFF ;Power up timer disabled
      LPBOREN = OFF ;ULPBOR disabled
      BOREN = SBORDIS ;Brown-out Reset enabled , SBOREN bit is ignored
      BORV = VBOR_285 ;Brown-out Reset Voltage (VBOR) set to 2.85V
      ZCD = OFF ;ZCD 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 ;WDT Disabled
      WDTCWS = WDTCWS_7 ;window always open (100%); software control; keyed access not required
      WDTCCS = SC ;Software Control
      WRT0 = OFF ;Block 0 (000800-003FFFh) not write-protected
      WRT1 = OFF ;Block 1 (004000-007FFFh) not write-protected
      WRT2 = OFF ;Block 2 (008000-00BFFFh) not write-protected
      WRT3 = OFF ;Block 3 (00C000-00FFFFh) not write-protected
      WRT4 = OFF ;Block 4 (010000-013FFFh) not write-protected
      WRT5 = OFF ;Block 5 (014000-017FFFh) not write-protected
      WRT6 = OFF ;Block 6 (018000-01BFFFh) not write-protected
      WRT7 = OFF ;Block 7 (01C000-01FFFFh) not write-protected
      WRTC = OFF ;Configuration registers (300000-30000Bh) not write-protected
      WRTB = OFF ;Boot Block (000000-0007FFh) not write-protected
      WRTD = OFF ;Data EEPROM not write-protected
      SCANE = OFF ;Scanner module is NOT available for use, SCANMD bit is ignored
      LVP = OFF ;HV on MCLR/VPP must be used for programming
      Cp = OFF ;UserNVM code protection disabled
      CPD = OFF ;DataNVM code protection disabled
      EBTR0 = OFF ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
      EBTR1 = OFF ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
      EBTR2 = OFF ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
      EBTR3 = OFF ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
      EBTR4 = OFF ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
      EBTR5 = OFF ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
      EBTR6 = OFF ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
      EBTR7 = OFF ;Block 7 (01C000-01FFFFh) 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
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    OSCFRQ = 6
    OSCCON1=%01100000
    OSCCON2=%01100000
    Xtal=32
    TRISA=%11111111
    TRISB=%00000000
    TRISC=%10001111
    TRISD=%11111111
    TRISE=%00000000
    ANSELA=%00000011
    ANSELB=0
    ANSELC=0
    ANSELD=0
    ANSELE=0
    ODCONA=0
    ODCONB=0
    INT0PPS=13
    INT1PPS=13
    INT2PPS=13
    CWG1PPS=13
    SSP2CLKPPS=13
    SSP2DATPPS=13
    SSP2SSPPS=13
    Dim mfp1in As Byte
    Dim mfp2in As Byte
    Dim mfp3in As Byte
    Dim mpen1in As Byte
    Dim mpen2in As Byte
    Dim mp616in As Byte
    Dim mp615in As Byte
    Dim mp614in As Byte
    Dim mp613in As Byte
    Dim mrevin As Byte
    Dim mfwdin As Byte
    Dim mmodein As Byte
    Dim pgrmnum As Byte
    Dim pgrmnum1 As Byte
    Dim pgrmnumtmp As Byte
    Dim pgrmnumtmp1 As Byte
    'Dim vfdfwd As Byte
    'Dim vfdrev As Byte
    'Dim notrim As Byte
    'Dim trim As Byte
    'Dim airsol As Byte
    'Dim hyd_down As Byte
    'Dim hyd_up As Byte
    Dim fp1 As Byte
    Dim fp2 As Byte
    Dim fp3 As Byte
    Dim pen1 As Byte
    Dim pen2 As Byte
    Dim p616 As Byte
    Dim p615 As Byte
    Dim p614 As Byte
    Dim p613 As Byte
    Dim rev As Byte
    Dim fwd As Byte
    Dim mode As Byte
    
    Symbol fp1in PORTD.5   '5
    Symbol fp2in PORTD.6   '6
    Symbol fp3in PORTD.7   '7
    Symbol pen1in PORTD.3   '3
    Symbol pen2in PORTD.4   '4
    Symbol p616in PORTC.0
    Symbol p615in PORTC.1
    Symbol p614in PORTC.2
    Symbol p613in PORTC.3
    Symbol revin PORTD.0
    Symbol fwdin PORTD.1
    Symbol modein PORTD.2
    Symbol vfdfwd PORTB.0
    Symbol vfdrev PORTB.1
    Symbol trim PORTB.2
    Symbol notrim PORTB.3
    Symbol airsol PORTE.0
    Symbol hyd_down PORTE.1
    Symbol hyd_up PORTE.2
    vfdfwd=0
    vfdrev=0
    trim=0
    notrim=0
    airsol=0
    hyd_down=0
    hyd_up=0
    Declare HRSOut_Pin = PORTC.6
    Declare Hserial_Baud =9600
    
    'goto loop3
    idnum:
            pgrmnumtmp=PORTA
            pgrmnum = pgrmnumtmp & %00111100
            Ror pgrmnum
            Ror pgrmnum
            DelayMS 40
            pgrmnumtmp1=PORTA
            pgrmnum1 = pgrmnumtmp1 & %00111100
            Ror pgrmnum1
            Ror pgrmnum1
            
            
            HRSOut Dec pgrmnum," x ",Dec pgrmnum1,10,13
            If pgrmnum1 <> pgrmnum Then GoTo idnum
            DelayMS 100
            
            
            
            If pgrmnum =1 Then ' Variable speed foot pedal hand operated top shaft
            HRSOut " pgrm =1  ",10,13
                notrim=0
                trim=1
                vfdfwd=0
                vfdrev=0
    loop1:  GoSub readinput
            'HRSOut "mode = ",dec mode,10,13
             If fp1=1 Then 
                If rev=1 Then vfdrev=1:vfdfwd=0
                If fwd=1 Then vfdrev=0:vfdfwd=1
                If fwd=0 And rev=0 Then vfdrev=0:vfdfwd=0
                
             Else
                vfdrev=0:vfdfwd=0
             
             EndIf   
                
            GoTo loop1
            EndIf
             
            If pgrmnum =2 Then ' Fwd/Rev foot pedal hand operated top shaft
            HRSOut " pgrm =2  ",10,13
                notrim=1
                trim=0
                vfdfwd=0
                vfdrev=0
    loop2:  GoSub readinput
            'HRSOut "mode = ",dec mode,10,13
            If fp1=1 And fp3=0 Then vfdfwd=1:vfdrev=0
            If fp1=0 And fp3=1 Then vfdfwd=0:vfdrev=1
            If fp1=0 And fp3=0 Then vfdfwd=0:vfdrev=0
            If fp1=1 And fp3=1 Then vfdfwd=0:vfdrev=0
           ' HRSOut "fwd = ",dec vfdfwd,"   rev = ",dec vfdrev,10,13
            HRSOut "fwd = ",Dec fp1,"   rev = ",Dec fp3,10,13
            GoTo loop2
            EndIf
            
            
            If pgrmnum =3 Then ' Variable speed foot pedal air operated top shaft
            HRSOut " pgrm =3  ",10,13
                notrim=0
                trim=1
                vfdfwd=0
                vfdrev=0
    loop3:  GoSub readinput
            'HRSOut "mode = ",dec mode,10,13
             If fp1=1 Then 
                If rev=1 Then vfdrev=1:vfdfwd=0:airsol=1
                If fwd=1 Then vfdrev=0:vfdfwd=1:airsol=1
                If fwd=0 And rev=0 Then vfdrev=0:vfdfwd=0:airsol=1
                
             Else
                vfdrev=0:vfdfwd=0:airsol=0
             
             EndIf   
                
            GoTo loop3
            EndIf
    
    
    
           If pgrmnum =4 Then ' Variable speed foot pedal air operated top shaft
            HRSOut " pgrm =4  ",10,13
                notrim=0
                trim=1
                vfdfwd=0
                vfdrev=0
    loop4:  GoSub readinput
            'HRSOut "mode = ",dec mode,10,13
             If fp1=1 Then 
                If rev=1 Then vfdrev=1:vfdfwd=0:airsol=1
                If fwd=1 Then vfdrev=0:vfdfwd=1:airsol=1
                If fwd=0 And rev=0 Then vfdrev=0:vfdfwd=0:airsol=1
                
             Else
                vfdrev=0:vfdfwd=0:airsol=0
             
             EndIf   
                
            GoTo loop4
            EndIf
    
    
            If pgrmnum =5 Then ' Variable speed foot pedal air operated top shaft
            HRSOut " pgrm =5  ",10,13
                notrim=0
                trim=1
                vfdfwd=0
                vfdrev=0
    loop5:  GoSub readinput
            'HRSOut "mode = ",dec mode,10,13
             If fp1=1 Then 
                If rev=1 Then vfdrev=1:vfdfwd=0:airsol=1
                If fwd=1 Then vfdrev=0:vfdfwd=1:airsol=1
                If fwd=0 And rev=0 Then vfdrev=0:vfdfwd=0:airsol=1
                
             Else
                vfdrev=0:vfdfwd=0:airsol=0
             
             EndIf   
                
            GoTo loop5
            EndIf
    
             If pgrmnum =6 Then ' Variable speed foot pedal air operated top shaft
            HRSOut " pgrm =6  ",10,13
               
    loop6:  GoSub readinput
            HRSOut Dec fp1,Dec fp2,Dec fp3,Dec pen1,Dec pen2,Dec rev,Dec fwd, Dec mode,10,13
             
                
            GoTo loop6
            EndIf
    
    
            GoTo idnum
            
    
    readinput:
            mfp1in = fp1in
            mfp2in = fp2in
            mfp3in = fp3in
            mpen1in = pen1in
            mpen2in = pen2in
            mp616in = p616in
            mp615in = p615in
            mp614in = p614in
            mp613in = p613in
            mrevin = revin
            mfwdin =  fwdin
            mmodein = modein
            DelayMS 40
            
            If fp1in = mfp1in Then fp1 = fp1in
            If fp2in = mfp2in Then fp2 = fp2in
            If fp2in = mfp2in Then fp3 = fp3in
            If pen1in = mpen1in Then pen1 = pen1in
            If pen2in = mpen2in Then pen2 = pen2in
            If p616in = mp616in Then p616 = p616in
            If p615in = mp615in Then p615 = p615in
            If p614in = mp614in Then p614 = p614in
            If p613in = mp613in Then p613 = p613in
            If revin = mrevin Then rev = revin
            If fwdin = mfwdin Then fwd = fwdin
            If modein = mmodein Then mode = modein
            
            Return
            
            End
    Last edited by geoff_c; 3rd January 2019 at 14:57.

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

  3. #2
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    439
    Thumbs Up
    Received: 84
    Given: 0
    Total Downloaded
    243.13 MB

    1 Not allowed!

    Default Re: 18F47K40 Port B issue

    Port B doesn't work at above 10 Mhz, other ports are fine
    I'm not exactly sure what you mean by that, but you might need to clear the slew-rate register(s) SLRCONx.
    They default to slow mode and need to be set = 0 for normal speed.

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

  5. #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,229
    Thumbs Up
    Received: 372
    Given: 131
    Total Downloaded
    1.58 GB

    1 Not allowed!

    Default Re: 18F47K40 Port B issue

    Tumbleweed is probably correct. PPS only comes into play on peripherals, not on standard I/O lines.

    As usual, Microchip have dropped another bollock and enabled something by default that should be up to the user to enable, otherwise, it can/will make a program not work. I've also had a few programs that the slew has stopped working, until they were disabled. The slew is something I am going to try to disable as standard, just like the compiler does to make analogue pins digital by default before the user's program starts. I'm also gong to try to disable DACs by default. It is a simple task, but the logistics are a problem because I have to go through each PPI file and identify the devices with the slew SFR and the DAC SFR and write the code at the bottom of the device's .def file, and there are hundreds of PPI files, and not all of them have the SFRs, and some will probably have a different mechanism for the SFRs. This is something Microchip are famous for! Change for the sake of change, and no other reason. :-(
    Last edited by top204; 4th January 2019 at 09:38.

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

  7. #4
    Member geoff_c's Avatar
    Join Date
    Oct 2002
    Posts
    187
    Thumbs Up
    Received: 1
    Given: 6
    Total Downloaded
    558.26 MB

    0 Not allowed!

    Default Re: 18F47K40 Port B issue

    Thanks Tumbleweed and Les. The slewrate was the problem, changed it to 0 and it worked perfect.

    Much appreciated
    Geoff

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

  9. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,229
    Thumbs Up
    Received: 372
    Given: 131
    Total Downloaded
    1.58 GB

    2 Not allowed!

    Default Re: 18F47K40 Port B issue

    I've made the changes to all the .def files for devices that contain the SLRCONx SFRs. i.e. Slew rate I/O pins.

    The next update to the compiler will make all pins TTL mode by default on devices that have the stupid slew rate enabled.

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

  11. #6
    Member geoff_c's Avatar
    Join Date
    Oct 2002
    Posts
    187
    Thumbs Up
    Received: 1
    Given: 6
    Total Downloaded
    558.26 MB

    1 Not allowed!

    Default Re: 18F47K40 Port B issue

    Thanks Les, really appreciate the speedy help and fix. I'm wishing I didn't choose the 18F47K40. I was just doing a fairly simple design but thought I should use a more modern pic. I should done more research before switching from the good old ones that worked so easy. I saw a couple new features like the averaging for the A to D.

    One question Im having problems with the AD now. Searching the forms that was a issue a while back and there was a workaround by using Adin_K40.inc. I tried that also and my code still didn't work didn't work. Just wondering if I should still be using that or if that been looked after the latest release. I have version 3627.

    Just about to try Timer1. Lol probably have issues with that to.

    Thanks
    Geoff

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

  13. #7
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,040
    Thumbs Up
    Received: 188
    Given: 169
    Total Downloaded
    4.36 GB

    0 Not allowed!

    Default Re: 18F47K40 Port B issue

    I realise that this might seem a backward step but if you're keen to "get on" with your project, the 18F26K22 sort of similar, lots of ROM and RAM in a 28pin package and runs at 64Mhz without a crystal but without PPS and wizz bang ADC. Probably it's biggest down side is the pins used for UART2.
    George.

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

  15. #8
    Member geoff_c's Avatar
    Join Date
    Oct 2002
    Posts
    187
    Thumbs Up
    Received: 1
    Given: 6
    Total Downloaded
    558.26 MB

    0 Not allowed!

    Default Re: 18F47K40 Port B issue

    Thanks If I could have got away with 28 pins that's the exact one I would have used as I have used that before on multiple designs with no problem. For the 64 pin ones Ive been using PIC18F67J10 and for the 44 pin one 18F4520 and 18F4685, Just wanted to move to something newer. Thought the PPS would have been handy in case I needed to change or add to the prototype. Big mistake I am so frustrated and so far behind now.

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

  17. #9
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,040
    Thumbs Up
    Received: 188
    Given: 169
    Total Downloaded
    4.36 GB

    0 Not allowed!

    Default Re: 18F47K40 Port B issue

    Sorry typo, should have been 18F46K22.
    George.

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

  19. #10
    Member geoff_c's Avatar
    Join Date
    Oct 2002
    Posts
    187
    Thumbs Up
    Received: 1
    Given: 6
    Total Downloaded
    558.26 MB

    0 Not allowed!

    Default Re: 18F47K40 Port B issue

    Almost tempted to change looks like they go back to 2010. I also use xtals just because im used to that. Are the onboard oscillators accurate and stable enough for serial communication.

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

  1. Remapping port pins and 16 bit port
    By RGV250 in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 5th January 2018, 18:35
  2. Replies: 4
    Last Post: 2nd May 2016, 15:10
  3. Crazy PORT.A Issue
    By Harrison in forum Proton Plus Compiler v3
    Replies: 19
    Last Post: 9th April 2015, 18:00
  4. 16F690 LCD on Port-B vs. Port-C
    By albertus0214 in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 17th July 2007, 07:23

Members who have read this thread since 15th June 2019, 14:46 : 0

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