SEROUT 12F683 and GPIO.5


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default SEROUT 12F683 and GPIO.5

    Ladies and Gents,
    I'm playing with Proteus and serial outputs on a 12F683 using GPIO.5 as my output to the serial display. When I use this code
    Code:
    clear
    trisio = %001000
    gpio = 0
    
    INCLUDE "modedefs.bas"
    DEFINE CHAR_PACING 1000
    
    
    define osc4  
    osccon = %01101110  ' sets int osc to 4 mhz
    
    ansel = 0          ' all ports digital
    cmcon0 = 7         ' comparators off
    adcon0 = 0         ' adc off
    
    b var byte
    c var byte
    y var byte
    pinout var gpio.5
    
    
    beginning:
    let b = 0
    let c = 0
    for b = 0 to 15
    'serout gpio.5,n9600,[10,13,13]
    '       pause 500
    serout gpio.5,n9600,["b=",#b," c=",#c,10,13,13]
    '       pause 500
    y = y + 1
    serout gpio.5,n9600,["number of trips ",#y,10,13,13]
        if b < 8 then 
           gpio = b
        else 
             c = b + 8
             gpio = c
        endif
        pause 500
    next b 
    
    goto beginning
    I get what I expect. That is LEDs hooked up to a 74154(?) BCD to 16 decoder counting from 0 to 15 and serial out to a display that can be read by humans.

    However, when I try to go to 8MHZ internal oscillator using this change
    Code:
    define osc8  
    osccon = %01111110  ' sets int osc to 4 mhz
    the LEDs count like expected but the serial out goes into Alien script mode.

    I haven't tried using another output pin as I'm unsure if that's the problem.

    Now the $64 question: Is there something special about GPIO.5 that needs to be accounted for to get serial out on that pin?

    Let the schooling begin!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: SEROUT 12F683 and GPIO.5

    Have you tried it on real hardware?
    Your OSCCON seems correct for 8MHz but it's my understanding that you ALSO have to tell Proteus at which frequency the virtual PIC is supposed to be running, it doesn't actually use the value of the x-tal or, in this case, the internal oscillator. I've never used it though so I may very well be wrong.

    /Henrik.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: SEROUT 12F683 and GPIO.5

    Proteus will adjust the internal oscillator frequency according to the OSCCON register, which overrides the oscillator frequency set in the parts dialog box.

    But your define osc8 is not correct.
    It should be ...
    Code:
    DEFINE OSC 8
    Without a correct DEFINE OSC, PBP assumes it is 4Mhz.
    DT

  4. #4
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: SEROUT 12F683 and GPIO.5

    Thanks, that appears to have fixed it. It's often the simplest of things.

  5. #5
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: SEROUT 12F683 and GPIO.5

    I went back to this program after doing some other things and found I'd missed part of the point. My define statement should have been in all caps and not used lower case characters. All the defines are case sensitive not just the define oscillator. I wish PBP would throw up an error during the complile as it surely could check for that. Of course, I may have shut that attention getter off at some previous session.

    I've promised myself I'd look back over the manual again to acquaint myself with the nuance of the language. Oh joy!

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: SEROUT 12F683 and GPIO.5

    It would be nice if microcode studio would make a permanent substitution along with a warning.

    Robert

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


    Did you find this post helpful? Yes | No

    Default Re: SEROUT 12F683 and GPIO.5

    Just code pbp with caps locked on... Then no worries .
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. 12F683: I change GPIO.5 but GPIO.0 also changes...why?
    By chicowoodhill in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th December 2012, 17:09
  2. Replies: 1
    Last Post: - 29th February 2012, 09:37
  3. 12F683 serout timing
    By Hobie Cat in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st December 2009, 16:57
  4. 12F683 GPIO.3 problem
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 30th October 2009, 08:43
  5. 12c508 Gpio
    By oki_one in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th August 2003, 07:51

Members who have read this thread : 2

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