Discussion in "PIC Microcontroller Discussion" started by    pappuneelam    May 1, 2011.
Tue May 24 2011, 02:53 pm
#21
did you disable watchdog in your LED blink program and LCD program?

and for LCD, 1K at contrast pin is sufficient. if you still face a problem replace it with a potentiometer for easy adjustment. Incase LCD still does not show up, increase delay everywhere.. try to double them up and see if it works.
Tue May 21 2013, 04:30 pm
#22
hallo mr.ajay....
can u please post the assembly code for displaying anything on the lcd in 4 bit mode....
i'm working with pic 16f913....
i just getting blocks in the led...i know it is the problem with the initialisation...how to initialise the lcd in 4 bit mode...
Wed May 22 2013, 09:43 am
#23
Wed May 22 2013, 01:04 pm
#24
but it is not working for my pic 16f913....
please give me the code
Thu May 23 2013, 10:11 am
#25
Sorry I do not have ready code for your controller. Share your code, lets see where you're going wrong.
Fri May 24 2013, 03:06 pm
#26
THIS IS MY CODE.....PLEASE GO THROUGH IT



list p=16f913 ; list directive to define processor
#include <p16f913.inc>


org 0x00

STATUS equ 03h
PORTA equ 05h
PORTC equ 07h
TRISA equ 85h
TRISB equ 86h
TRISC equ 87h

bsf STATUS,05


movlw 07h
movwf CMCON0
clrf ANSEL
movlw 0x00
movwf TRISA

movlw 0xfc
movwf TRISC

bcf STATUS,05

COUNT1 equ 50h
COUNT2 equ 51h

R1 equ 22h
R2 equ 23h
R3 equ 24h
R4 equ 25h
temp equ 26h
COUNT3 equ 23h
start
call delay_0
movlw 0x30
call m_init
call delay_1
movlw 0x30
call m_init
call delay_2
movlw 0x30
call m_init
call delay_2
movlw 0x20
call m_init
call delay_2
movlw 0x28
call mask1
movlw 0x08
call mask1
movlw 0x01
call mask1
movlw 0x06
call mask1
movlw 0x0e
call mask1
movlw 0x80
call mask1

;movlw 01h
;call mask1
movlw 'H'
call mask2
movlw 'a'
call mask2
movlw 'i'
call mask2
here goto here
m_init movwf temp
movlw 0xf0
movwf R1
movlw 0x0f
movwf R2
movf temp,w
andwf R1,1
swapf R1,1
andwf R2,1
;swapf R2,1
movf R1,w
call init
movf R2,w
call init
return
mask1 movwf temp
movlw 0xf0
movwf R1
movlw 0x0f
movwf R2
movf temp,w
andwf R1,1
swapf R1,1
andwf R2,1
;swapf R2,1
movf R1,w
call cmd
movf R2,w
call cmd
return
mask2 movwf temp
movlw 0xf0
movwf R3
movlw 0x0f
movwf R4
movf temp,w
andwf R3,1
swapf R3,1
andwf R4,1
;swapf R4,1
movf R3,w
call dat
movf R4,w
call dat
return

init movwf PORTA
bcf PORTC,0
bsf PORTC,1
call delay_0
bcf PORTC,1
; call delay_0
return
cmd
movwf PORTA
bcf PORTC,0
bsf PORTC,1
call delay_0
bcf PORTC,1
return
dat
movwf PORTA
bsf PORTC,0
bsf PORTC,1
call delay_0
bcf PORTC,1
return

delay_0
movlw 0x9F
movwf COUNT1
movlw 0x10
movwf COUNT2
LOOP_0
decfsz COUNT1, 1

decfsz COUNT2, 1
goto LOOP_0
return
;2 cycles
; goto $+1


delay_1
movlw 0xCF
movwf COUNT1
movlw 0x08
movwf COUNT2
loop_1
decfsz COUNT1,1

decfsz COUNT2,1
goto loop_1
return
;2 cycles
; goto $+1
delay_2
movlw 0xC7
movwf COUNT1
movlw 0x01
movwf COUNT2
loop_2
decfsz COUNT1,1
; goto $+2
decfsz COUNT2,1
goto loop_2
return
;2 cycles
;goto $+1


end


[ Edited Fri May 24 2013, 03:07 pm ]
Sat May 25 2013, 04:44 am
#27
This code is a really hard to follow, let alone debug.


I suggest you re-write it.
Don't mix equates and code.
Add lots of comments.
Explain how each subroutine works and the flow of the whole program.


list p=16f913 ; list directive to define processor
#include STATUS equ 03h
PORTA equ 05h
PORTC equ 07h
TRISA equ 85h
TRISB equ 86h
TRISC equ 87h

COUNT1 equ 50h
COUNT2 equ 51h
R1 equ 22h
R2 equ 23h
R3 equ 24h
R4 equ 25h
temp equ 26h
COUNT3 equ 23h //same as R2 ????


org 0x00 //program starts here at 0 (so you can't allow interrupts)

bsf STATUS,05
movlw 07h
movwf CMCON0
clrf ANSEL
movlw 0x00
movwf TRISA

movlw 0xfc
movwf TRISC

bcf STATUS,05


start //???
call delay_0
movlw 0x30
call m_init



[ Edited Sat May 25 2013, 04:46 am ]
 Curiou_Som like this.
Mon May 27 2013, 09:49 am
#28
I do not understand why you have to do this:
PORTA equ 05h
PORTC equ 07h
TRISA equ 85h
TRISB equ 86h
TRISC equ 87h


isn't it defined already in your assembler??

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am