Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 3rd June 2007, 04:20 PM   (permalink)
Default code help

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 emailktdksk@yahoo.com.au
emaney is offline   Reply With Quote
Old 3rd June 2007, 11:29 PM   (permalink)
Default

Quote:
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.
My PIC assembly is little rusty right now, but here goes a hint (untested)

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'
Disadvantage: if interrupt changes PORTA between andwf PORTA,w and movwf PORTA, the change will be reversed by this code.
__________________
www.dipmicro.com
dipmicro is offline   Reply With Quote
Old 4th June 2007, 02:30 PM   (permalink)
Default

orwf Mask,w....................little confused about this, gives error as well. iam still confused about it?
emaney is offline   Reply With Quote
Old 4th June 2007, 02:38 PM   (permalink)
Default

Quote:
Originally Posted by emaney
orwf Mask,w....................little confused about this, gives error as well. iam still confused about it?
This was just a hint a not a working code, I did not actually test it. The instruction that does not compile I meant IORWF - inclusive OR
__________________
www.dipmicro.com
dipmicro is offline   Reply With Quote
Old 20th June 2007, 12:57 AM   (permalink)
Default

Quote:
Originally Posted by dipmicro
My PIC assembly is little rusty right now, but here goes a hint (untested)

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'
Disadvantage: if interrupt changes PORTA between andwf PORTA,w and movwf PORTA, the change will be reversed by this code.
this program does not have to be interrupt driven......How do i define the input and output channel selection code......
emaney is offline   Reply With Quote
Old 22nd June 2007, 09:47 AM   (permalink)
Default

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
emaney is offline   Reply With Quote
Old 26th June 2007, 12:56 AM   (permalink)
Default

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
emaney is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
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



All times are GMT. The time now is 06:12 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.