Port A pins


Closed Thread
Results 1 to 4 of 4

Thread: Port A pins

  1. #1
    Join Date
    Jul 2006
    Posts
    6

    Smile Port A pins

    I am just getting into microcontroller programing and am haveing trouble geting the port A pins to go high and low. I dont really understand how to get thoes pins to go high and low. My micorcontroller is a pic16f84. If someone could give me the assembly code to make a specific A pin go high, and descrive exactly what is going on in the code I would appreciate it.

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Few start point
    http://www.picbasic.co.uk/forum/show...hlight=dummies

    Code:
    
    ;	Super dooper LED blink with 10F200
    ;	==================================
    ;	Steve Monfette
    ;	Mister E 
    ;	23/03/2006
    
    ;	As if the world really needed it... well it's still usefull
    ;	to learn a bit how to play and waste your time using the
    ;	annoying assembler language.  BTW 10F200 are just too small
    ;	to accept any other language.
    
    ;	This program will use a software loop delay, called by a macro
    ;	wich will pass the delay to produce... at least not too basic and
    ;	some part could be usefull.. one day if someones really try to figure
    ;	out how it works... just kidding.. i know EVERYBODY WILL TRY ;o)
    ;	---------------------------------------------------------------------
    
    	INCLUDE "P10F200.INC"	; load all needed stuff 
    
    ;	PIC configuration
    ;	=================
    	__Config _MCLRE_ON & _CP_OFF & _WDT_OFF
    	
    ;	Hardware assignement
    ;	====================
    	#define Led			GPIO,2	
    	
    ;	RAM assignement 
    ;	===============
    ; 	hands-up those who discover figure 4-3
    
    	cblock 0x10				
    		loop		
    		UserDelay
    	endc
    
    ;	Macro Definition
    ;	================
    ;	Be carefull, the following macro is extremely difficult to understand 
    ;	and contain tons of information... always refer to MPASM book to 
    ;	understand all trick it do.. mpff mkay i stop it :o)
    
    ;	Nothing fancy, the macro will just pass the parameter to the 1 msec
    ;	subroutine -> Delay <- Not much.  What could she do more to be still
    ;	code efficient anyway?
    
    Delayms	macro User				
    	movlw	User		; put User wish somewhere
    	movwf	UserDelay	; copy it to something
    	call 	Delay		; do the delay	
            endm				
        
    ;	///////////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    ;					Program Begining	
    ;	///////////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    
    ;	Hardware configuration
    ;	======================
    	ORG 0			; 
    	movwf	OSCCAL		; Load OSCCAL value
    
    	movlw	b'11111011' 	;
    	TRIS	GPIO		; Set GP2 as Output
    
    	movlw	b'11011111' 	; TOCS=internal => to use GP2 as Output 
    	OPTION			; => datasheet section 4.5	
    
    ;	Tha ****!
    ;	=========
    ;	The exciting part of the program... how to blink a LED
    Start
    	bsf 	Led		; Enable LED
    	Delayms d'250'		; do 250 mSec Delay	
    	bcf		Led	; Disable LED
    	Delayms	d'250'		; do 250 mSec Delay
    	goto 	Start		; Have fun forever, enjoy the show
    
    ;	Delay Subroutine
    ;	================
    ;	The main program call the macro, the macro call this routine
    Delay	
        	movlw   d'250'		; 1 mSec base
        	movwf   loop  		;	loop
    
       	;	DelayLoop
       	;	---------
        	nop  			; do nothing                (1 Cycle)
        	decfsz  loop,f	    	; base loop finished?       (1 cycle if NO, 2 cycle if YES)
        	goto    $-2 	  	; NO... jump 2 lines before (2 cycles)
        				;			    -------------------------------
        				;               Killed about 4 cycles * 250times @1uSec = 1mSec
        				; 
        	decfsz	UserDelay,f 	; DelayFinish?
        	goto 	$-6		; NO... do it again, jump 6 line before
        	retlw	0		; Astalavista baby
        	end
    Last edited by mister_e; - 11th July 2006 at 16:57.
    Steve

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

  3. #3
    Join Date
    Aug 2005
    Location
    Houston, TX
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Late but--

    Perhaps you have figured it out by now.

    Anyway, use "poke" + the "A" register + a binary discription of how you want the 4 pins.

    If you want them all high:

    POKE $5,%1111

    All low:

    POKE $5,%0000

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


    Did you find this post helpful? Yes | No

    Default

    i guess you misread the following part
    Quote Originally Posted by Eric123
    If someone could give me the assembly code to make a specific A pin go high, and descrive exactly what is going on in the code I would appreciate it.
    Steve

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

Similar Threads

  1. Indexing Port Pins
    By Bruce in forum Code Examples
    Replies: 6
    Last Post: - 5th January 2014, 08:31
  2. Pointers To Port Pins ?
    By BitHead in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd December 2009, 20:38
  3. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. PIC PORT 'special' pins
    By barkerben in forum General
    Replies: 1
    Last Post: - 18th January 2005, 21:40

Members who have read this thread : 0

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