Hserout/Hserin max.speed


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116

    Question Hserout/Hserin max.speed

    Hello insider world!

    my attempt to send a word and display it on a LCD works with serin and debug, now I try with

    HSEROUT/HSERIN and of course it fails.

    using two 16F628A with a single canned 20Mhz oscillator.

    '************************************************* *******************************************
    ' HSEROUTFAST1
    '16F628A canned 20MHz osc extern
    ' should count pulses on porta.0 and send by USART to PIC # 2
    '************************************************* *******************************************

    '
    ' DEFINITIONS

    @__config _EXTCLK_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF

    Include "modedefs.bas"
    CMCON=%00000111
    DEFINE OSC 20
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h '9600 baud rate, BRGH=1
    DEFINE HSER_BAUD 9600
    DEFINE HSER_SPBRG 129 '25 for 4MHz
    DEFINE HSER_CLROERR 1



    Cnt VAR Word ' Cnt is a word variable

    ' START OF MAIN PROGRAM
    ' ' Cnt is a word variable
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = %11111110 ' PORT A1 is input
    TRISB = %11111111 ' RB output
    cnt = 0


    main:


    COUNT PORTA.0,100,cnt ' Count for 1 second
    RCSTA.7 = 1 'usart enabled
    HSEROUT [0,cnt ,10,13]
    PAUSE 10
    RCSTA.7 = 0 'usart disabled

    goto main


    END ' End of program


    and here the recieving program :same setup as above + an lcd in standard configuration.

    '************************************************* *******************************************
    ' PIC#2 : 16F628A 20 Mhz extern canned oscillator same as PIC#1
    ' should recieve the variable cnt and show it on LCD
    '
    '************************************************* *******************************************

    '
    ' DEFINITIONS

    @__config _EXTCLK_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF

    Include "modedefs.bas"
    CMCON=%00000111
    DEFINE OSC 20

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h '9600 baud rate, BRGH=1
    DEFINE HSER_BAUD 9600
    DEFINE HSER_SPBRG 129 '25 for 4MHz
    DEFINE HSER_CLROERR 1



    Cnt VAR word ' Cnt is a word variable
    inputData var word ' variable to receive data into


    ' START OF MAIN PROGRAM
    '
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = %11111101 ' RB1 is Input others output
    cnt = 0
    main:

    Hserin [inputData]

    cnt = inputData

    LCDOUT $FE,2
    LCDOUT "cnt=", DEC4 cnt
    goto main


    END ' End of program

    I know HSerin needs some registers to enable and disable but thats too far for me now.

    Experience: you can force a 4Mhz PIC16F628A to run on 20MhZ with an extern osc..hehe, everything works..tried some ..hihi

  2. #2
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi

    I had just a quick glance through to check your Tris settings and came across this
    TRISB = %11111101 ' RB1 is Input others output
    ???

    Maybe have a look at the direction of TX/RX both should be set as inputs on both PICs

    Therefore on the 16F628A TX/RX are on portB1 and PortB2 respectively.

    there may be other issues, I have not studied further,

    HTH a little bit

    Duncan

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower
    TRISB = %11111101 ' <font color=red>RB1 is Input others output</font color
    1 is input, 0 is output, easy to remember 1 looks like I and 0 looks like O
    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.

  4. #4
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Question how many wires to use?

    do I need to connect both TX RX Lines on both pics crosswise because of some handshake signals or only one wire for sending from one pic to another? I didnīt find a picture of a master/slave configuration, exept Mister_eīs master/slave example wich is great but for serin/serout.
    Hey, how about something alike for Hserin/Hserout Mister_e?




    Pic 16f628a to pic 16F628a......

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    do I need to connect both TX RX Lines on both pics crosswise because of some handshake signals or only one wire for sending from one pic to another? I didnīt find a picture of a master/slave configuration, exept Mister_eīs master/slave example wich is great but for serin/serout.
    Hey, how about something alike for Hserin/Hserout Mister_e?

    Pic 16f628a to pic 16F628a......
    You do realize that the only major difference between SERIN/SEROUT and HSERIN/HSEROUT is that SERIN/SEROUT is bit-banged and HSERIN/HSEROUT uses the hardware USART module (if available) in the PIC...right?
    Therefore, any example that works with SERIN/SEROUT, should work with HSERIN/HSEROUT, if properly configured...and it follows that you would then have to...Read the datasheets/manuals for the particular device that you are using.

  6. #6
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Wink Bitbanger

    Hi Skimask,

    hmm...I can tell you the only thing I knew was that Hserin/Hserout uses the Usart and I hoped that because of this it could run the data transwer partially in the background .that means that the data-bits-pushing is performed with the minimum of software used to speed things up.

    because Iīm now thanks to your gurus of piclands help up to 20MHz I may use serin/serout with success....

    But: serin/serout and Debugin/Debug worked only with 4 MHz and 4800 baud . any change to that and my recieving PICs LCD showed rubbish. We had that before.

    I read cool examples with 112000 baud or so using debug, but that was on "strange" 18F Pics I canīt handle by now.

    Maybe I have to switch to a "modern" usart-preferred-PIC with goes along with lots of tutorials or examples or so. The only thing about the usart in the 16F628A I found in the data sheet was "Usart:Y" and the codes for the TX and RX registers.

    Tell you what: the learning curve is way steep for an oldschool mechanical engineer of 44 years in foreign language...
    Last edited by Mugelpower; - 19th February 2008 at 08:15. Reason: syntax

Members who have read this thread : 1

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