Discussion in "PIC Microcontroller Discussion" started by    needginer    Oct 4, 2007.
Thu Oct 04 2007, 02:57 pm
#1
hi, im a microcontroller beginner, how to write a program in asm to inteface the pic877 with the sram. any example code that showing out to 8 leds. let say i want to an eight 8 bis data into the pic and display on the leds. through the SRAM before display the output.
PIC -> SRAM -> PIC -> 8 LEDs
need ur help very much, thank.
Thu Oct 04 2007, 03:14 pm
#2
take a look at this snippet............
hope it will help

RC4 -> led Anode
led Cathode -> 1K res
1K res -> ground

;
Title "led flasher."
;
list P = 16F877
;
include "P16f877.inc" ; use definition file for 16F877
;
; --------------------
; USER RAM DEFINITIONS
; --------------------
;
CBLOCK 0x20 ; RAM starts at address 20h
NaHi
NaLo
NbHi
NbLo
ENDC
;
org 0x0000 ; start address = 0000h

; INITIALISE PORTS
; binary used to see individual pin level

movlw b'00000000' ; all port pins = low
movwf PORTA
movlw b'00000000'
movwf PORTB
movlw b'00000000'
movwf PORTC
movlw b'00000000'
movwf PORTD
movlw b'00000000'
movwf PORTE

bsf STATUS,RP0 ; set RAM Page 1 for TRIS registers

; INITIALISE PORTS
; binary used to see individual pin IO status

movlw b'00000000' ; all IO pins = outputs
movwf TRISA
movlw b'00000000'
movwf TRISB
movlw b'00000000'
movwf TRISC
movlw b'00000000'
movwf TRISD
movlw b'00000000'
movwf TRISE

movlw b'00000110' ; all analog pins = digital
movwf ADCON1

bcf STATUS,RP0 ; back to RAM page 0

; led FLASH LOOP

Loop bsf PORTC,4 ; RC4 = high = led on
call Delay

bcf PORTC,4 ; RC4 = low = led off
call Delay
goto Loop

; 1/2 SEC DELAY SUBROUTINE WITH 4MHz CLOCK

Delay movlw 01h
movwf NbHi
movlw 03h
movwf NbLo
movlw 8Ah
movwf NaHi
movlw 5Bh
movwf NaLo

DeLoop0 decfsz NaLo,F
goto DeLoop0
decfsz NaHi,F
goto DeLoop0
decfsz NbLo,F
goto DeLoop0
decfsz NbHi,F
goto DeLoop0
;
return

end

Thu Feb 28 2008, 10:38 am
#3
want 2 share my temperature alarm project with u..
using PIC16C71..

PORTA EQU 05
PORTB EQU 06
STATUS EQU 03
ADCON0 EQU 1F
ADRES EQU 1E
C EQU 0C

ORG 0x00
GOTO start


start MOVLW b'00000001'
TRIS PORTA
MOVLW 0x00
TRIS PORTB

MOVLW b'00001111'
OPTION

MOVLW b'01000001'
MOVWF ADCON0

main
BSF ADCON0,2


ISR BCF ADCON0,1
MOVLW d'18'
SUBWF ADRES,W
BTFSS STATUS,C
GOTO cold

MOVLW d'23'
SUBWF ADRES,W
BTFSS STATUS,C
GOTO OK
GOTO hot


cold MOVLW b'00000001'
MOVWF PORTB
RETFIE

OK MOVLW b'00000010'
MOVWF PORTB
RETFIE

hot MOVLW b'00000100'
MOVWF PORTB
RETFIE

END

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm
Robertgurse
Wed Apr 24 2024, 02:43 pm