18f25k22 hserin


+ Reply to Thread
Results 1 to 18 of 18

Thread: 18f25k22 hserin

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 18f25k22 hserin

    works as expected
    only slight change was to move serout to portb.7 to suit my pickit2 debug uart tool and put something printable
    into BArray

    Code:
    '-------------------------------------------------------------------------' Name  : Hserin Test  (18F25K22)
    ' Serout Baud rate: 188:4800,84:9600,49:14400,32:19200,15:28800,6:38400  'ok
    ' Serout : p296,297
    ' 9600 Open Inverted None 49236
    ' HSERIN [WAIT("!"), STR MyArray\200, STR MyArray(200)\200, _
    ' STR MyArray(400)\200, STR MyArray(600)\100]
    '
    '-------------------------------------------------------------------------
     Include "modedefs.bas" ' Include serial modes
    ;----[18F25K22 Hardware Configuration]------------------------------------------
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = On   
      CONFIG  WDTEN = Off       
      CONFIG  MCLRE = INTMCLR   
      CONFIG  LVP = Off
    #ENDCONFIG
    
    
    
    
        ANSELA = 0  ; All Digital
        ANSELB = 0
        ANSELC = 0
    DEFINE OSC 64                     
    TRISA = % 11111111    '1:IN, 0:OUT             
    TRISB = % 11111111
    TRISC = % 11111111                   
    OSCCON = $70
    OSCTUNE = $40                     
    
    
    
    
    
    
    
    
    ' Set receive register to receiver enabled
    DEFINE HSER_RCSTA 90h
    DEFINE HSER2_RCSTA 90h
    ' Set transmit register to transmitter enabled
    DEFINE HSER_TXSTA 20h
    DEFINE HSER2_TXSTA 20h
    ' Set baud rate
    DEFINE HSER_BAUD 9600 
    DEFINE HSER2_BAUD 9600
    DEFINE HSER_CLROERR 1
    
    
    
    
    
    
    
    
    AArray VAR BYTE[12]
    BArray VAR BYTE[12]   
    
    
     ARRAYWRITE BARRAY,["GOT IT",0]
    
    
    
    
    ' code to scan sample : 0 59749 96859 1                     
    MAIN:                             
    
    
    
    
    HSERIN [wait ("0"), str AArray\12]
    serOut2 PORTB.7,84, [str BArray,13,10]
    
    
    GoTo MAIN
    what doesn't work are code snippets and failure to provide connection details [ schematic]
    and even a description of what happens versus what you expect to happen


    Name:  jbergs.jpg
Views: 2576
Size:  99.5 KB
    Last edited by richard; - 19th January 2025 at 23:56.
    Warning I'm not a teacher

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 18f25k22 hserin

    more useful would be


    Code:
    '-------------------------------------------------------------------------' Name  : Hserin Test  (18F25K22)
    ' Serout Baud rate: 188:4800,84:9600,49:14400,32:19200,15:28800,6:38400  'ok
    ' Serout : p296,297
    ' 9600 Open Inverted None 49236
    ' HSERIN [WAIT("!"), STR MyArray\200, STR MyArray(200)\200, _
    ' STR MyArray(400)\200, STR MyArray(600)\100]
    '
    '-------------------------------------------------------------------------
     Include "modedefs.bas" ' Include serial modes
    ;----[18F25K22 Hardware Configuration]------------------------------------------
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = On   
      CONFIG  WDTEN = Off       
      CONFIG  MCLRE = INTMCLR   
      CONFIG  LVP = Off
    #ENDCONFIG
    
    
    
    
        ANSELA = 0  ; All Digital
        ANSELB = 0
        ANSELC = 0
    DEFINE OSC 64                     
    TRISA = % 11111111    '1:IN, 0:OUT             
    TRISB = % 11111111
    TRISC = % 11111111                   
    OSCCON = $70
    OSCTUNE = $40                     
    
    
    
    
    
    
    
    
    ' Set receive register to receiver enabled
    DEFINE HSER_RCSTA 90h
    DEFINE HSER2_RCSTA 90h
    ' Set transmit register to transmitter enabled
    DEFINE HSER_TXSTA 20h
    DEFINE HSER2_TXSTA 20h
    ' Set baud rate
    DEFINE HSER_BAUD 9600 
    DEFINE HSER2_BAUD 9600
    DEFINE HSER_CLROERR 1
    
    
    
    
    
    
    
    
    AArray VAR BYTE[12]
    BArray VAR BYTE[12]   
    
    
     ARRAYWRITE BARRAY,["GOT IT",0]
    
    
    
    
    ' code to scan sample : 0 59749 96859 1                     
    MAIN:                             
    
    
    
    
    HSERIN [wait ("0"), str AArray\12]
    serOut2 PORTB.7,84, [str BArray,13,10]
    hserout ["got", str AArray\12 ,13,10]
    
    
    
    
    GoTo MAIN
    Name:  jberg.jpg
Views: 2509
Size:  85.3 KB
    Warning I'm not a teacher

  3. #3
    Join Date
    Jan 2022
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: 18f25k22 hserin

    Hello everyone, and thank to all for helping me

    this case is solved!


    1st

    the GM65 scanner Tx/Rx line are at 3.3v not at standard 5V TTL logic, so I add a BSS138 between the Tx and the Rx (HSerin) of the PIC

    2nd

    I like to thank also BrianS (HSERIN issue with a 18F452 and IF THEN statements or Case statements)


    while reading about his case I took part of the HSerin setup and added to my program, first try work just fine on HSerin/HSerin2.

    Code:
    '-------------------------------------------------------------------------
    ' Name : Hserin Test  (18F25K22)
    '-------------------------------------------------------------------------
     Include "modedefs.bas" ' Include serial modes
    ;----[18F25K22 Hardware Configuration]------------------------------------------
    
    
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = ON
      CONFIG  WDTEN = Off       
      CONFIG  MCLRE = INTMCLR   
      CONFIG  LVP = Off
    #ENDCONFIG
    
    '-------------------------
    DEFINE HSER_CLROERR 1
    DEFINE HSER_BAUD 9600
    RCSTA = $90
    TXSTA = $20
    DEFINE HSER2_CLROERR 1
    DEFINE HSER2_BAUD 9600
    RCSTA2 = $90
    TXSTA2 = $20
    '-------------------------
    
    
       ANSELA = 0  ; All Digital
       ANSELB = 0
       ANSELC = 0
    DEFINE OSC 64 
                        
    TRISA = 111101    '1:IN, 0:OUT             
    TRISB = 000001
    TRISC = 111101                   
    OSCCON = $70
    OSCTUNE = $40                     
    
    
    AArray VAR BYTE[12]
    
    
    ' code to scan sample : 0 59749 96859 1                     
    
    MAIN:                             
    
    
    HSERIN 50,MAIN,[STR AARRAY\12]
    'HSERIN2 50,MAIN,[STR AARRAY\12]
    
    ' --------------------------------------------
    serOut2 PORTB.1,84, [str aarray\12,13,10]
    ' --------------------------------------------
    
    
    GoTo MAIN


    Name:  GM65 SPEC.jpg
Views: 2409
Size:  163.7 KB


    Name:  BSS138 CIRCUIT FROM SPARKFUN.png
Views: 2515
Size:  58.3 KB


    Name:  terminal-2.jpg
Views: 2300
Size:  44.0 KB



  4. #4
    Join Date
    Jan 2022
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: 18f25k22 hserin

    Many thanks richard.

    Take care.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: 18f25k22 hserin

    No code error , no compiler deficiency. as suggested in post #9 its wired incorrectly

    who would have known
    Warning I'm not a teacher

  6. #6
    Join Date
    Jan 2022
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: 18f25k22 hserin

    Specialy when the GM65 user manual mention TTL logic level, yes the DC supply is 5V, for the USB / UART ports.

    but it's not specify 3.3V Tx/Rx output line.

    Learning everyday like everyone here.

Similar Threads

  1. Hserin
    By Dinoden in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th December 2016, 04:16
  2. 18F25K22 Help
    By ERMEGM in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 25th November 2014, 10:36
  3. migration from 16F876a to 18F25k22
    By MOUNTAIN747 in forum General
    Replies: 26
    Last Post: - 19th March 2012, 21:33
  4. Config 18F25K22
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2011, 19:08
  5. hserin
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 21st February 2007, 18:15

Members who have read this thread : 13

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