SEROUT on a 16F1947


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2016
    Posts
    3

    Default SEROUT on a 16F1947

    Hello,
    I hope someone can help me with a basic problem.
    Using a 16F1947 and trying to get SEROUT to work.

    This started as a product board upgrade from a 16F77 to a 16F1947
    All else works, but I dont get any serial data out on the new chip.


    So, I stripped down the code to simplify the problem.
    Here is my code:

    Include "modedefs.bas"
    ANSELF = 0
    Pattern var byte
    Pattern = 0

    SO var PortF.2

    Start:
    High SO
    Pause 10
    Low SO
    Pause 10

    Pattern = Pattern + 1
    Serout SO,4,[Pattern]
    Goto Start

    It toggles the pin on for 10 mS then off for about 14mS.
    There is no data output ever (using a o-scope, not a pc to look at it)
    If I comment out the Serout line, I get 10 mS on and 10 mS off so the serout command is doing something for 4 ms.
    I dont need the High or Low commands, but put them in to see if the pin was working ok.
    If I comment out the High and Low commands I get no output at all.

    I've tried using PortF.2 in place of SO, same result.
    Tried using different pins, but no data out.
    Tried not using a variable, like SEROUT PortF.2,4,["Data"] same result.
    Tried different data rates, same result.
    Tried SEROUT2, same results.

    Using a 4.00 MHz resonator

    I would think the A/D and such are set to digital ok because the High and Low work correctly.

    Does a 16F1947 not work with SEROUT commands?

    Thanks for looking!

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


    Did you find this post helpful? Yes | No

    Default Re: SEROUT on a 16F1947

    I would think the A/D and such are set to digital ok because the High and Low work correctly.
    High & Low do all the analog vs Digital manipulation for you, I suspect you are
    having an analog (default state) issue.
    Take sure any comparators are off on that port pin . . . I have never seen serout used the way you are trying to use it, try sending some text.
    Last edited by Archangel; - 4th February 2016 at 05:50.
    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.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: SEROUT on a 16F1947

    I would start here

    http://support.melabs.com/content/56...f-16F1946-1947
    Published on 12-04-2013 10:03 AM

    With PBP 2.60 and later (up to 3.0.7.x), PBP commands that automatically set the TRIS bits will not work properly on PORTF or PORTG of the 16F1946/1947.

    An issue with bank selection for the TRIS register has been identified.

    Hopefully, this will be corrected by version 3.0.8.x
    2.60(A,B,C) will continue to have this issue.

    There are no workarounds.

  4. #4
    Join Date
    Feb 2016
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: SEROUT on a 16F1947

    Thanks for looking at it!
    I've tried a few more things, ending with:

    Include "modedefs.bas"

    ANSELF = 0 'Set PortF to digital
    TRISF = 0 'PortF = outputs
    ADCON0 = 0 'Turn off A/D

    Low PortF.1

    Start:
    Toggle PortF.1
    Pause 10
    Serout PortF.2,4,["data"]
    Goto Start

    There is no serial data coming out of PortF.2, but PortF.1 toggles about every 26mS.

    When it says there is no work around, does that mean I cant set them manually and there is no way to make it work?

    Or, am I still missing a setup for the A/D or something?

    Thanks!

  5. #5
    Join Date
    Feb 2016
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: SEROUT on a 16F1947

    Ok, I have it working.
    Thank you for pointing me in the right direction about the compiler not working well with the 1947 chip yet.

    Here is what I did to make it work:
    (I only need to send one byte at a time at 2400 baud, so it works ok for now)

    Include "modedefs.bas"

    ANSELF = 0
    TrisF = 0

    SO var PortF.2
    Pattern var byte

    Start:

    Pause 200
    Pattern = Pattern + 1
    Gosub SendSerial ' Serout PortF.2,4,[Pattern]
    Goto Start

    SendSerial:
    High SO
    PauseUs 416

    If Pattern.0 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.1 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.2 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.3 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.4 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.5 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.6 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    If Pattern.7 = 1 then
    High SO
    PauseUS 410
    Else
    Low SO
    PauseUS 410
    Endif

    Low SO
    PauseUS 416

    Return

Similar Threads

  1. PULSIN ON PORTF and PORTG ON 16F1947
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 9th December 2013, 01:54
  2. Replies: 10
    Last Post: - 26th November 2013, 09:38
  3. Help with, SEROUT
    By Kimto in forum mel PIC BASIC
    Replies: 6
    Last Post: - 29th March 2006, 09:15
  4. serout
    By jonas2 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th February 2006, 16:50
  5. Serout IR TX
    By Jųan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th January 2006, 00:53

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