Port 'a' problems


Closed Thread
Results 1 to 15 of 15
  1. #1
    Join Date
    Jul 2007
    Posts
    18

    Question Port 'a' problems

    I am writing a very simple (theoretically) string of code to flash some LED's in a variety of patterns on a 12 segment bar graph. I am using a 16f628a. Port b outputs are a ok and working a treat. As you can see by lines 4 & 5 I have set my 'a' ports as standard I/O (or so I thought). However whenever I try to set two 'a' ports high at the same time only one will go high.

    Does anyone know how to make the 'a' ports on a 16f628a act like normal old good old 84a I/O ports.

    I have attached the code and a pinout for the Bargraph. Please ignore the fact that the first loop excludes any following code from being run--this loop is a late edition for debugging only.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Robotica1; - 14th July 2007 at 14:06. Reason: Trying attachments

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


    Did you find this post helpful? Yes | No

    Default

    http://www.picbasic.co.uk/forum/showthread.php?t=562

    http://www.picbasic.co.uk/forum/showthread.php?t=561

    These are from the FAQ - Frequently Asked Questions section, read them and see if it helps. Basically You will need to MAKE the pins NORMAL.

    If you still have problems let us know.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    first thing to understand why it doesn't work, is to open the datasheet and look what the 628 have that the 84 don't.

    Now you discover that the F628 it have analog comparator on PORTA. WOOOOHOOO, but it doesn't solve the problem yet.

    Before using those pins as regular i/o, you need to set them as digital.

    Find the Analog comparator section in the datasheet, and look the CMCON settings.

    Now you understand that you'll need to use...
    Code:
    CMCON=7
    at the top of your code.

    HTH

    EDIT: oups, i'm late
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jul 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Question First thing I did.

    Thanks for the help but no joy. I already knew about the port 'a' comparator story.. hence lines 4&5 of my code

    movlw 7
    movwf CMCON

    I understand that as having the same effect as CMCON=7 (I even tried changing a couple of nights ago just to check). As long as only one port needs to be high there is no problem it is only when two or more want to be high simultaneously??? I am really frustrated as this was for a birthday present which is kind of due tomorrow??

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


    Did you find this post helpful? Yes | No

    Default

    Hey, you got attachments!!

    The
    Code:
    movlw 7
    
       movwf CMCON
    is assembly. if you are going to write it that way you need to let the program know .
    Code:
    ASM
    movlw 7
    
       movwf CMCON
    ENDASM
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    can you post your whole code here?

    If you do it in asm, make sure you're in the right BANK first.. unless, you may have no joy at all. BANKSEL comes handy... IN 100% ASM ONLY. If you're using a mix of PBP and assembler, you NEED to use
    CHK?RP CMCON

    instead of BANKSEL.

    HEY, wait a minute... the code you posted in your first post is not PBP, but something close to ASM and BASIC??? What is it?

    Sure it's based on Skimask's wishes
    Last edited by mister_e; - 14th July 2007 at 14:22.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Mister_E,
    Look at the first post. Attachments are there now.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Jul 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Thanks for the help...still dazed and confused

    That's the only assembly routine I have in the code. It's all attached but if you need I'll include in the body of a post. Yeah Dave (Don't know what was happening there with attachments...thanks again). Anyway I tried CMCON=7 and CMCON=%00000111. When the code hits "high l9:high l11ause 3:"..l9 flashes (almost imperceptibly) then l11 goes high. When it gets to the next section ('High l10:low l11:high l12) then l10 goes high and l12 does nothing!!

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    what happen if you remove all those colon in your code???

    Pause 3, seems really fast so far... 300 could be more interesting.

    Not sure of those multiple...
    Code:
    RETURN
    END
    L12 refer to RA.4, and it's an open drain type. You can't drive a LED as you wish. At least, you could drive it if it's connected between Vdd, and the PIC, not between GND and PIC
    Last edited by mister_e; - 14th July 2007 at 14:30.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Jul 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Pause 3 and colons

    I have a pause of 3 because I am using an external clock signal from a 555 astable with an adjustable (low) frequency ( so that the flash rate is adjustable). It is definately a visible speed. The colons are there because I had each sequence on it's own line earlier. I split the lines and left the colon's because I read something last night in an old post by ski-mask discussing something along these lines. I just recoded without the colons as I'm typing this and nothing changed at all.

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


    Did you find this post helpful? Yes | No

    Default

    What Mister_E said about RA.4 might be it -- or -- Looking at the two attachments it might be a combination of code and hardware. In the code I do not see a complimentary pin all of the time.

    I made this up for some hide I work with, it explains what I am getting at.
    http://mackrackit.com/mac/www/dave/LED/LEDs.html
    Dave
    Always wear safety glasses while programming.

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I don't understand why it shouldn't work unless you have an hardware problem OR a bad configuration fuse setting.....

    what happen with that one???
    Code:
            @       __CONFIG  _INTRC_OSC_NOCLKOUT & _MCLRE_OFF  &  _LVP_OFF & _WDT_OFF & _PWRTE_ON  & _BODEN_ON  
            '
            '       or use the one bellow if you use PM assembler
            '   @       device  pic16F628A, intrc_osc, wdt_on, mclr_on, lvp_off, protect_off 
            PORTB = 0
            PORTA = 0
            TRISB = 0
            TRISA = 0
            CMCON = 7
            
    START:
            PORTA = 255
            PORTB = 255
            PAUSE   200
            PORTA = 0
            PORTB = 0        
            PAUSE   200
            GOTO    START
    but yeah... pure assumption, no schematic available, and i need more cofee
    Last edited by mister_e; - 14th July 2007 at 14:52.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Jul 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default ra4 allocation

    Sorry, forgot to fix that...I only did that as another debug...original code was
    Code:
     symbol l9= porta.0
    symbol l10= porta.1
    symbol l11= porta.2
    symbol l12= porta.3
    I reallocated to see if it was a problem with ra0 as it was the original playup pin. I have now set it back!! As far as some complimentary others not etc. If you look at the LED setup for the Bargraph hardware some (ie l1, l4, l9 and l12) are standalone LEDs whereas (l2,l3...l5,l6...l7,l8...and l10,l11) are wired in sequence. This means if I want to light LED 1 I send l1 high. If I want to light LED 2 I have to send l2 high and l3 low etc.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Robotica1 View Post
    This means if I want to light LED 1 I send l1 high. If I want to light LED 2 I have to send l2 high and l3 low etc.
    Right, but
    Quote Originally Posted by Robotica1 View Post
    When the code hits "high l9:high l11ause 3:"..l9 flashes (almost imperceptibly) then l11 goes high. When it gets to the next section ('High l10:low l11:high l12) then l10 goes high and l12 does nothing!!
    Code:
    high l9:high l11:pause 3:
    
    	  low l9:low l11
    
    	  high l10:low l11:high l12:pause 3:
    
    	  low l10:low l12
    But something does not look right in the above.
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Possible to have a schematic? Picture worth thousands words

    an yup, i feel it could be done in few code lines. i bet on 50% reduction here, maybe more...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. port config.
    By tamertokgoz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th July 2008, 12:25
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. Notebook Com Port win2k problems
    By folkc in forum Serial
    Replies: 4
    Last Post: - 20th February 2006, 16:16
  4. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21
  5. Port pin problems
    By sgreelish in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th March 2004, 18:56

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