![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
i real need somones help with this pic16f84a question
A de-multiplexer has an input line, pinRB0, and four output lines, output0 to output3, which are, respectively, the pins RA0-RA3. the demultiplexer copies the digital signal appearing on the input line on to one of the four output lines. The output line is selected by a two bit selection code input on the pins RB1 and RB2. i have this code that does the following The following program, in assembly language of the pic16f84A microcontroller, configures the three ; lower pins of PORTA(RA0, RA1 and RA2) as inputs, and the pins of PORTB as output. The program then ;enters a non-terminating loop. in the loop program read the three input lines, interpret the input as ;a 3 bit binary value(RA0 as the least significant bit), and make PORTB line corresponding to the ;input value 'on' by outputting the value '1' on this line. ;All other output lins must remain '0'. #DEFINE PAGE0 BCF 0x03,5 #DEFINE PAGE1 BSF 0x03,5 PCL: EQU 0x02 STATUS: EQU 0x03 PORTA: EQU 0x05 TRISA: EQU 0x05 PORTB: EQU 0x06 TRISB: EQU 0x06 W: EQU 0 F: EQU 1 ORG 0x0 goto MAIN org 5 MAIN: clrf PORTA clrf PORTNB PAGE1 movlw B'00000111' iorwf TRISA,F ;RA0-RA2 as input clrf TRISB ;Port B0-B7 as output PAGE0 LOOPX: movf PORTA. W andlw B'00000111' call TABLE movfw PORTB goto LOOPX TABLE: addwf PCL, F retlw B'00000001' retlw B'00000010' retlw B'00000100' retlw B'00001000' retlw B'00010000' retlw B'00100000' retlw B'01000000' retlw B'10000000' END after goign through this code anybody can tell me how can code teh above question(can anybody the code so it does what i asked at the top) i just hope iam clear enough.....please if u can send resoponse to my email |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Code:
loop: ;get the output selector movf PORTB,w rrf WREG andlw B'00000011' ;convert 0-3 to bit-mask call table movwf Mask ;switch all zeroes to ones in mask and vice versa xorlw B'11111111',w ;read all the bits of PORTA but the selected one (leave it clear) andwf PORTA,w ;if PORTB.0 is set, set also selected output in PORTA btfsc PORTB,0 orwf Mask,w ;write modified value back to PORTA movwf PORTA goto loop table: addwf PCL,F retlw B'00000001' retlw B'00000010' retlw B'00000100' retlw B'00001000'
__________________
www.dipmicro.com |
||
|
|
|
|
|
(permalink) |
|
orwf Mask,w....................little confused about this, gives error as well. iam still confused about it?
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
www.dipmicro.com |
||
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) |
|
please could anyone giv help on this, because the loop iam not understanding. if someone can just give pseudocode, because iam not sure how i can write up the code for the given question
|
|
|
|
|
|
|
(permalink) |
|
ok i know iam askign too much but i realy need someonce to help me with the above code, i have exam on thursday and i have to do this code to practice for the exam..........please
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Accessing EEPROM | Clayton | Micro Controllers | 15 | 23rd March 2007 03:00 AM |
| Need PIC16F84A Cool Project | Agent 009 | Micro Controllers | 158 | 11th March 2007 06:14 AM |
| Need some help with a code provided by ATMEL | ikalogic | Micro Controllers | 1 | 23rd January 2007 02:45 PM |
| Tough assembly program for the PIC16F84 | asmpic | Micro Controllers | 34 | 3rd December 2004 06:50 PM |
| An error in pic16f84a, why? | Zener_Diode | Micro Controllers | 6 | 11th April 2004 02:55 AM |