Announcement

Collapse
No announcement yet.

HSEROUT Woes with PIC18F67K40

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Success!!

    Had to specifically set the Output PPS register - RC6PPS = %00001100

    Comment


    • #17
      makes sense, but you have to ask why did you get some sort of output previously . weird

      Comment


      • #18
        I've written and tested examples for our K40 D-Stick. They were tested on the 47K40, but I think they will offer clues for the 67K40 as well. Low-voltage programming is enabled in configuration and I don't think the ANSELC register exists on the 67K40.

        Here's a simple HSER example:

        Code:
        ' Name        : hser_echo.pbp
        ' Compiler    : PICBASIC PRO Compiler 3.1
        ' Assembler   : MPASMX
        ' Target PIC  : 40-pin Advanced D-Stick (PIC18F47K40), note CONFIG LVP = ON for D-Stick
        ' Hardware    : Lab-X1
        ' Oscillator  : 64MHz Internal Oscillator
        ' Keywords    : LAB-X1, HSEROUT
        ' Description : PICBASIC PRO program responds to any character received with HSERIN (on RC7)
                        ' by repeating the character with HSEROUT (on RC6).
        
        DEFINE OSC 64
        
        DEFINE HSER_RCSTA  90h
        DEFINE HSER_TXSTA  24h
        DEFINE HSER_BAUD 115200
        
        char    VAR     BYTE
        
        ' Congigure I/O Digital/Analog ********************************
        ANSELA = %00001101  ' RA0, RA1, RA3 analog, other PORTA digital
        ANSELB = %00000000  ' PORTB digital
        ANSELC = %00000000  ' PORTC digital
        ANSELD = %00000000  ' PORTD digital
        ANSELE = %000  ' PORTE digital
        
        
        HSEROUT ["READY",13,10]
        
        mainloop:  
                HSERIN  [char]
                HSEROUT [char]
        
            GOTO mainloop
        
        '''''''''''''''''''''''' Configuration Directives ''''''''''''''''''''''''''''''       
        #CONFIG
            CONFIG FEXTOSC = OFF     ;Oscillator not enabled
            CONFIG RSTOSC = HFINTOSC_64MHZ     ;HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
            CONFIG CLKOUTEN = OFF     ;CLKOUT function is disabled
            CONFIG CSWEN = ON     ;Writing to NOSC and NDIV is allowed
            CONFIG FCMEN = ON     ;Fail-Safe Clock Monitor enabled
            CONFIG MCLRE = EXTMCLR     ;If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR
            CONFIG PWRTE = ON     ;Power up timer enabled
            CONFIG LPBOREN = OFF     ;ULPBOR disabled
            CONFIG BOREN = ON     ;Brown-out Reset enabled according to SBOREN
            CONFIG BORV = VBOR_245     ;Brown-out Reset Voltage (VBOR) set to 2.45V
            CONFIG ZCD = OFF     ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
            CONFIG PPS1WAY = OFF     ;PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence)
            CONFIG STVREN = ON     ;Stack full/underflow will cause Reset
            CONFIG DEBUG = OFF     ;Background debugger disabled
            CONFIG XINST = OFF     ;Extended Instruction Set and Indexed Addressing Mode disabled
            CONFIG WDTCPS = WDTCPS_31     ;Divider ratio 1:65536; software control of WDTPS
            CONFIG WDTE = ON     ;WDT enabled regardless of sleep
            CONFIG WDTCWS = WDTCWS_7     ;window always open (100%); software control; keyed access not required
            CONFIG WDTCCS = LFINTOSC     ;WDT reference clock is the 31.0 kHz LFINTOSC
            CONFIG WRT0 = OFF     ;Block 0 (000800-003FFFh) not write-protected
            CONFIG WRT1 = OFF     ;Block 1 (004000-007FFFh) not write-protected
            CONFIG WRT2 = OFF     ;Block 2 (008000-00BFFFh) not write-protected
            CONFIG WRT3 = OFF     ;Block 3 (00C000-00FFFFh) not write-protected
            CONFIG WRT4 = OFF     ;Block 4 (010000-013FFFh) not write-protected
            CONFIG WRT5 = OFF     ;Block 5 (014000-017FFFh) not write-protected
            CONFIG WRT6 = OFF     ;Block 6 (018000-01BFFFh) not write-protected
            CONFIG WRT7 = OFF     ;Block 7 (01C000-01FFFFh) not write-protected
            CONFIG WRTC = OFF     ;Configuration registers (300000-30000Bh) not write-protected
            CONFIG WRTB = OFF     ;Boot Block (000000-0007FFh) not write-protected
            CONFIG WRTD = OFF     ;Data EEPROM not write-protected
            CONFIG SCANE = ON     ;Scanner module is available for use, SCANMD bit can control the module
            CONFIG LVP = ON     ;Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored
            CONFIG CP = OFF     ;UserNVM code protection disabled
            CONFIG CPD = OFF     ;DataNVM code protection disabled
            CONFIG EBTR0 = OFF     ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR1 = OFF     ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR2 = OFF     ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
            CONFIG EBTR3 = OFF     ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
            CONFIG EBTR4 = OFF     ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR5 = OFF     ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR6 = OFF     ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
            CONFIG EBTR7 = OFF     ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
            CONFIG EBTRB = OFF     ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
        #ENDCONFIG
        Charles Leo
        ME Labs, Inc.
        http://melabs.com

        Comment


        • #19
          On my computer the document outlining the CONFIG is: C:/ProgramFiles(x86)/PBP3_1/DEVICES

          Near the top of the appropriate Devices sheet is what PBP puts in the code as default. I copy the entire thing, remove the semi-colons, then go back over each one to determine if it's appropriate. Below the default list each CONFIG is listed with all possible options. I'll copy/paste the one I need into the already copy/pasted default. This way I don't miss anything.
          We can crack this cotton PIC'n thang!

          Comment


          • #20
            Thanks for all the input - greatly appreciated.

            Andy

            Comment

            Working...
            X