[SOLVED !] Undiagnosed Problem with PIC18F46K80


Closed Thread
Results 1 to 5 of 5

Thread: Undiagnosed Problem with PIC18F46K801777 days old

  1. #1
    rpm26
    Guest rpm26's Avatar

    0 Not allowed!

    Post Undiagnosed Problem with PIC18F46K80

    Hi All,

    I've had some complex code running for a long time on a PIC18F46K80 - multiple routines, include files and such like.

    I recently miniaturised the electronics and in the process moved across to the 18F46K80. My connections and broad brush set-up are identical.

    However, none of the code works and after 24 hours trying to debug it I have got no further. For a start none of the SD card libraries work any more. I've checked the obvious PIC pin allocations and put a scope on the in/out lines to verify data is travelling both ways. I just get an SD_Init_FS failure when I either use the hardware MSSP version or the SHOut/In version of the macro/routines. Secondly, communication with my GSM module has also failed. And thirdly I see wierd timing errors.

    I have thus far:
    - Moved back to an external 20MhZ osc, and disabled the PLL.
    - Double checked my timing settings. I now have Serout working on a fixed Baud to my PC so am confident this is right (I also ran a blinking LED to count the cycle time)
    - Stripped back the code and gradually added things back in.

    I am focussing on debugging two specifc areas of code as I guess this would unlock the problem.

    Firstly, the following code copies byte-by-byte from one string to another, replacing chr 10 and 13 with a readable character. It worked fine in the original program:

    Code:
    SerOut PC_TX, 84, ["i15:", 13]
    For i15 = 0 To 250 
            SerOut PC_TX, 84, ["*", Dec i15, 13]
            If GSM_Response[i15] = 10 Then
                LogMessage[i15] = "_"
            ElseIf GSM_Response[i15] = 13 Then
                LogMessage[i15] = "_"
            Else
                LogMessage[i15] = GSM_Response[i15]
            EndIf                     
        Next i15
        LogMessage[255] = 0
    SerOut PC_TX, 84, [13, "5: "]
    The declares relating to the above are:
    Dim i15 as byte
    Dim LogMessage As String * 255
    Dim GSM_Response As String * 250

    The Serout is purely there for debug and I read it through my PC. The code never progresses past this procedure - I see the "i15:" but never the "5:". In fact I see i15 increment as expected _1 _2 _3 etc, but it jumps from _128 to _1 and keeps redoing that loop. When I had a different i byte variable I saw the same behaviour except it looped at 116. Am I missing something? I will copy the ASM into a follow-up post.

    Secondly, there is a good 30 second gap between me seeing the "1c" on serial and the "2" on serial within the routine below:
    Code:
    SerOut PC_TX, 84, ["1c", 13]
    
        Low GSM_RTS
        'Max 200 byte response
        HSerIn 190, tout2d, [Str GSM_Junk]
        tout2d:
        High GSM_RTS
        
        SerOut PC_TX, 84, ["2:", GSM_Junk, 13]
    GSM_Junk just has 2 characters in it (I also checked with the Len routine) as I expect. Input serial line looks clean to me.

    I am running the PIC at 3V and my config fuses are:
    Code:
    Config_Start
      RETEN = OFF    ;Ultra low-power regulator is Disabled (Controlled by REGSLP bit)
      INTOSCSEL = High    ;LF-INTOSC in High-power mode during Sleep
      SOSCSEL = High    ;High Power SOSC circuit selected
      XINST = On    ;Enabled
      FOSC = HS2    ;HS oscillator (High power, 16 MHz - 25 MHz)
      PLLCFG = OFF    ;Disabled
      FCMEN = OFF    ;Disabled
      IESO = OFF    ;Disabled
      PWRTEN = OFF    ;Disabled
      BOREN = SBORDIS    ;Enabled in hardware, SBOREN disabled
      BORV = 3    ;1.8V
      BORPWR = ZPBORMV    ;ZPBORMV instead of BORMV is selected
      WDTEN = SWDTDIS    ;WDT enabled in hardware; SWDTEN bit disabled
      WDTPS = 1048576    ;1:1048576
      CANMX = PORTB    ;ECAN TX and RX pins are located on RB2 and RB3, respectively
      MSSPMSK = MSK7    ;7 Bit address masking mode
      MCLRE = On    ;MCLR Enabled, RE3 Disabled
      STVREN = On    ;Enabled
      BBSIZ = BB2K    ;2K word Boot Block size
      Cp0 = OFF    ;Disabled
      CP1 = OFF    ;Disabled
      CP2 = OFF    ;Disabled
      CP3 = OFF    ;Disabled
      CPB = OFF    ;Disabled
      CPD = OFF    ;Disabled
      WRT0 = OFF    ;Disabled
      WRT1 = OFF    ;Disabled
      WRT2 = OFF    ;Disabled
      WRT3 = OFF    ;Disabled
      WRTC = OFF    ;Disabled
      WRTB = OFF    ;Disabled
      WRTD = OFF    ;Disabled
      EBTR0 = OFF    ;Disabled
      EBTR1 = OFF    ;Disabled
      EBTR2 = OFF    ;Disabled
      EBTR3 = OFF    ;Disabled
      EBTRB = OFF    ;Disabled
    Config_End
    All help gratefully received! As I say its code that worked fine before, all I've done is change the PIC.

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.

  • #2
    rpm26
    Guest rpm26's Avatar

    0 Not allowed!

    Default Re: Undiagnosed Problem with PIC18F46K80

    Here is the ASM for my first 'routine' as promised - from the .lst file

    Code:
    000040A8            15614 F3_000581 equ $ ; IN [GSM_SARA.INC] FOR i15 = 0 TO 250
    0040A8 6A58           15615     Clrf i15,0
    0040AA                15616 _FRLB__335
    0040AA 0EFB           15617     Movlw 251
    0040AC 5C58           15618     Subwf i15,W,0
    0040AE B0D8           15619     Btfsc STATUS,0,0
                          15620     [email protected] _NXLB__336
      000040B4            15621 F3_000582 equ $ ; IN [GSM_SARA.INC] SEROUT PC_TX, 84,["_", DEC i15, 13]
    0040B4 0E83           15622     Movlw PORTD
    0040B6 6E02           15623     Movwf GEN,0
    0040B8 0E40           15624     Movlw 64
    0040BA 6E09           15625     Movwf GENH,0
    0040BC 6A35           15626     Clrf PP5H,0
    0040BE 0E54           15627     Movlw 84
    0040C0 6E34           15628     Movwf PP5,0
    0040C2 6A06           15629     Clrf GEN3H,0
    0040C4 6A05           15630     Clrf GEN3,0
    0040C6 0E20           15631     Movlw 32
    0040C8 6E01           15632     Movwf BPFH,0
    0040CA 0E5F           15633     Movlw 95
                          15634     [email protected] _SEROUT__
    0040D0 5058           15635     Movf i15,W,0
                          15636     [email protected] [email protected]
    0040D6 0E0D           15637     Movlw 13
                          15638     [email protected] _SEROUT__
      000040DC            15639 F3_000583 equ $ ; IN [GSM_SARA.INC] if GSM_Response[i15] = 10 THEN
    0040DC EE08 F04B      15640     Lfsr 0,GSM_Response
    0040E0 5058           15641     Movf i15,W,0
    0040E2 26E9           15642     Addwf FSR0L,F,0
    0040E4 0E00           15643     Movlw 0
    0040E6 22EA           15644     Addwfc FSR0H,F,0
    0040E8 50EF           15645     Movf INDF0,W,0
    0040EA 6E13           15646     Movwf PBP#VAR1,0
    0040EC 0E0A           15647     Movlw 10
    0040EE 5C13           15648     Subwf PBP#VAR1,W,0
    0040F0 A4D8           15649     Btfss STATUS,2,0
                          15650     [email protected] _LBL__339
      000040F6            15651 F3_000584 equ $ ; IN [GSM_SARA.INC] LogMessage[i15] = "_"
    0040F6 EE00 F0B1      15652     Lfsr 0,LogMessage
    0040FA 5058           15653     Movf i15,W,0
    0040FC 26E9           15654     Addwf FSR0L,F,0
    0040FE 0E00           15655     Movlw 0
    004100 22EA           15656     Addwfc FSR0H,F,0
    004102 0E5F           15657     Movlw 95
    004104 6EEF           15658     Movwf INDF0,0
                          15659     [email protected] _LBL__338
      0000410A            15660 F3_000585 equ $ ; IN [GSM_SARA.INC] ELSEIF GSM_Response[i15] = 13 THEN
    00410A                15661 _LBL__339
    00410A EE08 F04B      15662     Lfsr 0,GSM_Response
    00410E 5058           15663     Movf i15,W,0
    004110 26E9           15664     Addwf FSR0L,F,0
    004112 0E00           15665     Movlw 0
    004114 22EA           15666     Addwfc FSR0H,F,0
    004116 50EF           15667     Movf INDF0,W,0
    004118 6E13           15668     Movwf PBP#VAR1,0
    00411A 0E0D           15669     Movlw 13
    00411C 5C13           15670     Subwf PBP#VAR1,W,0
    00411E A4D8           15671     Btfss STATUS,2,0
                          15672     [email protected] _LBL__340
      00004124            15673 F3_000586 equ $ ; IN [GSM_SARA.INC] LogMessage[i15] = "_"
    004124 EE00 F0B1      15674     Lfsr 0,LogMessage
    004128 5058           15675     Movf i15,W,0
    00412A 26E9           15676     Addwf FSR0L,F,0
    00412C 0E00           15677     Movlw 0
    00412E 22EA           15678     Addwfc FSR0H,F,0
    004130 0E5F           15679     Movlw 95
    004132 6EEF           15680     Movwf INDF0,0
                          15681     [email protected] _LBL__341
    004138                15682 _LBL__340
      00004138            15683 F3_000587 equ $ ; IN [GSM_SARA.INC] else
      00004138            15684 F3_000588 equ $ ; IN [GSM_SARA.INC] LogMessage[i15] = GSM_Response[i15]
    004138 EE08 F04B      15685     Lfsr 0,GSM_Response
    00413C 5058           15686     Movf i15,W,0
    00413E 26E9           15687     Addwf FSR0L,F,0
    004140 0E00           15688     Movlw 0
    004142 22EA           15689     Addwfc FSR0H,F,0
    004144 CFEF F01C      15690     Movff INDF0,PBP#VAR2
    004148 EE00 F0B1      15691     Lfsr 0,LogMessage
    00414C 5058           15692     Movf i15,W,0
    00414E 26E9           15693     Addwf FSR0L,F,0
    004150 0E00           15694     Movlw 0
    004152 22EA           15695     Addwfc FSR0H,F,0
    004154 C01C FFEF      15696     Movff PBP#VAR2,INDF0
      00004158            15697 F3_000589 equ $ ; IN [GSM_SARA.INC] endif
    004158                15698 _LBL__341
    004158                15699 _LBL__338
    004158                15700 _CTLB__337
      00004158            15701 F3_000590 equ $ ; IN [GSM_SARA.INC] NEXT i15
    004158 2A58           15702     Incf i15,F,0
    00415A A0D8           15703     Btfss STATUS,0,0
                          15704     [email protected] _FRLB__335
    00415E                15705 _NXLB__336
      0000415E            15706 F3_000591 equ $ ; IN [GSM_SARA.INC] LogMessage[255] = 0
    00415E 0101           15707     Movlb 1
      00000001            15708 RAM_Bank = 1
    004160 6BB0           15709     Clrf LogMessage#255,1
      00004162            15710 F3_000593 equ $ ; IN [GSM_SARA.INC] SEROUT PC_TX, 84,[13, "5: ", GSM_Response, 13]

  • 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
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default Re: Undiagnosed Problem with PIC18F46K80

    What was your original PIC? You appear to have quoted 18F46K80 twice.
    I recall that enabling XINST fuse can cause some unexpected problems

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

  • #4
    rpm26
    Guest rpm26's Avatar

    0 Not allowed!

    Default Re: Undiagnosed Problem with PIC18F46K80

    Quote Originally Posted by pic-ignorant View Post
    What was your original PIC? You appear to have quoted 18F46K80 twice.
    I recall that enabling XINST fuse can cause some unexpected problems
    Sorry, original PIC was 18F67J50. Will try the fuse ... Thanks!

  • 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
    rpm26
    Guest rpm26's Avatar

    0 Not allowed!

    Default [SOLVED!] Re: Undiagnosed Problem with PIC18F46K80

    pic-ignorant, your tip reference the XINST fuse was spot on. Solved everything. Frustrating having wasted nearly on two days debugging, but c'est la vie. Thanks!

  • 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. Config PIC18F46K80 for HSerOut
      By normnet in forum Proton Plus Compiler v3
      Replies: 4
      Last Post: 23rd March 2014, 14:38

    Members who have read this thread since 6th November 2019, 12:12 : 0

    Actions :  (Set Date)  (Clear Date)

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

    Tags for this Thread

    Posting Permissions

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