Addressing multiple PORTs using one Variable


+ Reply to Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Addressing multiple PORTs using one Variable

    Yes, ports will be in a sequential order.

    I'll be using ports:
    • Seconds: PORTC.3
    • Minutes Units: PORTC.4
    • Minutes Thenths: PORTC.5
    • Hours Units: PORTC.6
    • Hours Tenths: PORTC.7


    16F690 has:
    PORTA.0..5
    PORTB.4..7
    PORTC.0..7
    Last edited by flotulopex; - 25th July 2024 at 07:41.
    Roger

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


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    By changing pinsel var you can select different portc pins
    if you need the remaining portc pins then more code is needed



    Code:
    ' PIC 16F690 @20MHz#CONFIG
        __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_HS_OSC &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
    #ENDCONFIG
    
    
    TRISC = %00000000
    
    
    DEFINE OSC 20
    
    
    
    
    pinsel  var byte 
    pinsel   = 128 ;  64 FOR RC:6    32 FOR RC:5 ETC 
    
    
    
    
    MAIN:
    
    
        PORTC        = PORTC  | pinsel
    
    
            ASM
                nop
                nop
                nop
            ENDASM
        PORTC = 0         ' have this syntax for tests only here
            ASM
                nop
            ENDASM
            
        GOTO MAIN
    END
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    have you tried to light a rgb led strip with a 690 @20mHz yet ?
    i have doubts that such a slow chip will do the deed
    Warning I'm not a teacher

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    Quote Originally Posted by richard View Post
    have you tried to light a rgb led strip with a 690 @20mHz yet ?
    i have doubts that such a slow chip will do the deed
    That's why I proposed APA102 chips. Not strict on the clock frequency.

    Ioannis
    Last edited by Ioannis; - 25th July 2024 at 22:21.

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Addressing multiple PORTs using one Variable

    have you tried to light a rgb led strip with a 690 @20mHz yet ?

    Check this:
    Roger

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Addressing multiple PORTs using one Variable

    And here's the project's code for now.
    Attached Files Attached Files
    Roger

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    Have not checked al of your code, but in the ***_B routine you include many time the same code. Why not insert it one time and then use GoSub to it? Better efficiency and memory usage.

    Also I see you insist on using this difficult protocol. Consider the APA101 as it is less strict and can be used on slow MCUs

    Ioannis

Similar Threads

  1. Addressing ports via offset using lookup command
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 1st November 2013, 03:50
  2. How to drive 7 segment using multiple ports?
    By guess79 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:43
  3. multiple ports ===> one symbol?
    By PICMAN in forum General
    Replies: 4
    Last Post: - 8th March 2005, 22:24
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46
  5. Reading multiple ports
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th May 2004, 17:22

Members who have read this thread : 17

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