Hserout


Closed Thread
Results 1 to 12 of 12

Thread: Hserout

  1. #1
    Join Date
    May 2015
    Posts
    7

    Default Hserout

    Hi,
    I need to do serial output with PIC12F675 using HSEROUT.

    It's possible?

    Sorry for my English speech.

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


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    no get a 12f1822

  3. #3
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    Or just use SEROUT (no "H")

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


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    Or use the DEBUG function, usually makes smaller code.
    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
    Join Date
    May 2015
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    I just used SEROUT.

  6. #6
    Join Date
    May 2015
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    Firstly I want to apologise for my English speech.
    What's wrong with my code? Receiver will not turning on LED, when transmitter sending command.

    Transmitter:
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _CP_OFF & _MCLRE_OFF & _BODEN_OFF  & _PWRTE_OFF
    #ENDCONFIG
    DEFINE OSC 4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    DEFINE SER_BAUD 1200 
    DEFINE SER_CLROERR 1
    
    
    CMCON = 7 : TRISIO = %00010001 : ADCON0.7 = 1 : ANSEL = %00011001
    
    
    LED var GPIO.2
    i var byte
    Akumuliatorius VAR word
    Lygis var word
    Buves var word : Buves = 0
    Buves1 var word
    Buves2 var word
    
    
    Adr1 var byte : Adr1 = %00111110
    Adr2 var byte : Adr2 = %01101110
    CMD1 VAR BYTE : cmd1 = %10111110
    CMD2 var byte : cmd2 = %10011100
    pause 100
    
    
    FOR i = 1 TO 3
    high led : pause 400
    low led : pause 400
    NEXT i
       
    main:
    ADCIN 0, akumuliatorius
    
    
    if akumuliatorius <= 640 then
    high led
    else
    low led
    endif
    
    
    adcin 3, lygis
    
    
    Buves1 = Buves - 4 : Buves2 = Buves + 4
    
    
    if Lygis <= Buves1 or Lygis >= Buves2 then
    buves = lygis
    SEROUT2 GPIO.1,813,[Adr1,Adr2,Lygis,CMD1,CMD2]
    endif
    
    
    goto main
    end
    Receiver:
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _CP_OFF & _MCLRE_OFF & _BODEN_OFF  & _PWRTE_OFF
    #ENDCONFIG
    DEFINE OSC 4
    DEFINE SER_BAUD 1200
    DEFINE SER_CLROERR 1
    
    
    CMCON = 7 : TRISIO = %00100000
    
    
    LED var GPIO.0
    i var byte
    
    
    Adr1 var byte : Adr1 = %00111110
    Adr2 var byte : Adr2 = %01101110
    CMD1 VAR BYTE
    CMD2 var byte
    Lygis var word
    pause 100
    
    
    FOR i = 1 TO 3
    high led : pause 400
    low led : pause 400
    NEXT i
       
    main:
    SERIN2 GPIO.5,813,[wait (Adr1,Adr2),Lygis,cmd1,cmd2]
    pause 10      
    if cmd1 = %10111110 and cmd2 = %10011100 then
    high led
    else
    low led
    endif
    pause 10
    goto main
    end

  7. #7
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    Hi Mazytis,

    One quick observation with your receiver code - your "pause 10" time is incredibly short. I doubt you will actually be able to see the LED change status

    Cheers
    Barry
    VK2XBP

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    from the manual
    SERIN2
    is not supported on 12-bit core PIC MCUs due to RAM and stack
    constraints
    use serin

  9. #9
    Join Date
    May 2015
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    Still not working... :/

    Transmitter:
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _CP_OFF & _MCLRE_OFF & _BODEN_OFF  & _PWRTE_OFF
    #ENDCONFIG
    DEFINE OSC 4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    DEFINE SER_BAUD 2400 
    DEFINE SER_CLROERR 1
    
    CMCON = 7 : TRISIO = %00010001 : ADCON0.7 = 1 : ANSEL = %00011001
    INCLUDE "modedefs.bas"
    
    LED var GPIO.2
    i var byte
    Akumuliatorius VAR word
    Lygis var word
    Buves var word : Buves = 0
    Buves1 var word
    Buves2 var word
    
    Adr1 var byte : Adr1 = %00111110
    Adr2 var byte : Adr2 = %01101110
    CMD1 VAR BYTE : cmd1 = %10111110
    CMD2 var byte : cmd2 = %10011100
    pause 100
    
    FOR i = 1 TO 3
    high led : pause 400
    low led : pause 400
    NEXT i
       
    main:
    ADCIN 0, akumuliatorius
    
    if akumuliatorius <= 640 then
    high led
    else
    low led
    endif
    
    adcin 3, lygis
    
    Buves1 = Buves - 4 : Buves2 = Buves + 4
    
    if Lygis <= Buves1 or Lygis >= Buves2 then
    buves = lygis
    SEROUT GPIO.1,T2400,[Adr1,Adr2,Lygis,CMD1,CMD2]
    endif
    
    goto main
    end
    Receiver:
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _CP_OFF & _MCLRE_OFF & _BODEN_OFF  & _PWRTE_OFF
    #ENDCONFIG
    DEFINE OSC 4
    DEFINE SER_BAUD 2400
    DEFINE SER_CLROERR 1
    
    CMCON = 7 : TRISIO = %00100000
    INCLUDE "modedefs.bas"
    
    LED var GPIO.0
    i var byte
    
    Adr1 var byte
    Adr2 var byte
    CMD1 VAR BYTE
    CMD2 var byte
    Lygis var word
    pause 100
    
    FOR i = 1 TO 3
    high led : pause 400
    low led : pause 400
    NEXT i
      
    main:
    SERIN GPIO.5,T2400,[Adr1,Adr2,Lygis,CMD1,CMD2] 
    if Adr1 = %00111110 and ADR2 = %01101110 and cmd1 = %10111110 and cmd2 = %10011100 then
    high led : pause 100
    else
    low led
    endif
    goto main
    end

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    add a sync chr to the tx eg
    SEROUT GPIO.1,T2400,["*",Adr1,Adr2,Lygis,CMD1,CMD2]

    rx becomes

    SERIN GPIO.5,T2400,["*"],Adr1,Adr2,Lygis,CMD1,CMD2


    syntax for logical expressions is best done in parenthesis

    if (Adr1 = %00111110) and (ADR2 = %01101110) and (cmd1 = %10111110 )and (cmd2 = %10011100) then

    

  11. #11
    Join Date
    May 2015
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    Still the same. Maybe I don't configured something?

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    Did you find this post helpful? Yes | No

    Default Re: Hserout

    you might have a rmw issue

    try this


    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _CP_OFF & _MCLRE_OFF & _BODEN_OFF  & _PWRTE_OFF
    #ENDCONFIG
    DEFINE OSC 4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    DEFINE SER_BAUD 2400 
    DEFINE SER_CLROERR 1
    
    CMCON = 7 : TRISIO = %00010001 : ADCON0.7 = 1 : ANSEL = %00011001
    INCLUDE "modedefs.bas"
    
    LED var GPIO.2
    i var byte
    Akumuliatorius VAR word
    Lygis var word
    Buves var word : Buves = 0
    Buves1 var word
    Buves2 var word
    
    Adr1 var byte : Adr1 = %00111110
    Adr2 var byte : Adr2 = %01101110
    CMD1 VAR BYTE : cmd1 = %10111110
    CMD2 var byte : cmd2 = %10011100
    pause 100
    
    FOR i = 1 TO 3
    high led : pause 400
    low led : pause 400
    NEXT i
       
    main:
    ADCIN 0, akumuliatorius
    
    if akumuliatorius <= 640 then
    high led
    else
    low led
    endif
    gpio.0=1
    adcin 3, lygis
    
    Buves1 = Buves - 4 : Buves2 = Buves + 4
    
    if Lygis <= Buves1 or Lygis >= Buves2 then
    buves = lygis
    SEROUT GPIO.1,T2400,["*",Adr1,Adr2,Lygis,CMD1,CMD2]
    endif
    
    goto main
    end

Similar Threads

  1. HSEROUT Disable
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th January 2012, 23:50
  2. HSEROUT problem
    By karlosguay in forum Serial
    Replies: 3
    Last Post: - 11th January 2012, 19:44
  3. Hserout
    By Andre_Pretorius in forum Serial
    Replies: 3
    Last Post: - 7th June 2007, 04:45
  4. Hserout
    By MICOCALI in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 7th August 2004, 18:08
  5. HSEROUT and 16F628A
    By fredblah in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th May 2004, 00:07

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