strange problem with HSERIN


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This is the program code. the hserin2 is only used. I'm using a 20Mhz OSC.
    HSERIN2 is only used for chips with two hardware serial ports/
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Aug 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    HSERIN2 is only used for chips with two hardware serial ports/
    The 18f85j11 has 2 serial ports. 1 EUSART and 1 AUSART. I should be able to use this command.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    OOPPSS

    Maybe this???
    The pins of the AUSART module are multiplexed with
    the functions of PORTG (RG1/TX2/CK2 and
    RG2/RX2/DT2, respectively). In order to configure
    these pins as an AUSART:
    • bit SPEN (RCSTA2<7>) must be set (= 1)
    • bit TRISG<2> must be set (= 1)
    • bit TRISG<1> must be cleared (= 0) for
    Asynchronous and Synchronous Master modes
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default idle state

    Hi Beginner,
    One thing to check is the port's idle state. HSER* requires the port to idle HIGH so you will need a pull up resistor or the port will likely hang the program.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    One thing to check is the port's idle state. HSER* requires the port to idle HIGH so you will need a pull up resistor or the port will likely hang the program.
    Joe,

    Thanks for the heads up on that, but most of the samples I've come across have something like
    Code:
     IF RCIF THEN GOSUB xxxxx
    or
     IF RCIF=1 THEN GOSUB xxxxx
    If the pins are tied high then this will cause the code to constantly loop to the sections that deal with the comms. would it not be better to tie the pins to ground via resistors ?

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The USART RX pin should definitely idle high, but this routine has some major issues;
    Code:
    BEGIN: 
       For K = 240 TO 240  ' <-- BIG problem here
        teller = teller + 1   
        ADRESS = K
        AANTAL = 1 
        buffero(K) = teller  ' <-- there is no buffero(240)
        GoSub WEGSCHRIJVEN
        PauseUs 200
        ADRESS = K
        AANTAL = 1 
        GoSub OPHALEN 
        IF OK = 1 Then
         lcdbufO(K) = bufferi(K) ' <-- same issue here
         LCDBUFI(K) = BUFFERO(K) ' <-- and here
         GoSub LCD 
         OK = 0
        GoTo HIER1
        EndIF
       LCDBUFO(K) = 0
       LCDBUFI(K) = 0
       GoSub LCD
    HIER1:  Next
    K = 240, but your largest array variables are only 6 bytes. I.E. buffero(0) to buffero(5) would be the last byte available in your buffero array.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Uhmm... just looked at the schematic in the EasyPIC5 manual, the RX line is connected direct to the R1Out pin on the Max232 - the TX pin to the T1in pin which is tied to Vcc via 1K resistor. I assume the MAX232 will handle the logic level of the RX pin ?

  8. #8
    Join Date
    Aug 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    The USART RX pin should definitely idle high, but this routine has some major issues;
    Code:
    BEGIN: 
       For K = 240 TO 240  ' <-- BIG problem here
        teller = teller + 1   
        ADRESS = K
        AANTAL = 1 
        buffero(K) = teller  ' <-- there is no buffero(240)
        GoSub WEGSCHRIJVEN
        PauseUs 200
        ADRESS = K
        AANTAL = 1 
        GoSub OPHALEN 
        IF OK = 1 Then
         lcdbufO(K) = bufferi(K) ' <-- same issue here
         LCDBUFI(K) = BUFFERO(K) ' <-- and here
         GoSub LCD 
         OK = 0
        GoTo HIER1
        EndIF
       LCDBUFO(K) = 0
       LCDBUFI(K) = 0
       GoSub LCD
    HIER1:  Next
    K = 240, but your largest array variables are only 6 bytes. I.E. buffero(0) to buffero(5) would be the last byte available in your buffero array.
    I tried to change the For K = 240 TO 240 to For K = 0 TO 5 , but it does not make any difference.

    The chip still keeps running VERY slow (like 25 seconds startup time) when I'm using the HSERIN command.

    ---------------------

    The RS232 schematic is ok, I'm using the same for other PCB's with 16f887 and 16f882 chips where it works fine.
    ----------------------

    Also changing the bit TRISG<2> = 1 does not solve this problem.

    Any more suggestions?

Members who have read this thread : 0

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