CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LCD 16X2 hanging problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
samuel.sam77



Joined: 21 Feb 2012
Posts: 3
Location: Coimbatore

View user's profile Send private message Send e-mail AIM Address Yahoo Messenger

LCD 16X2 hanging problem
PostPosted: Mon Apr 28, 2014 2:34 am     Reply with quote

Hi

The lcd hanging problem 16x2 while connecting with metal enclosure 230v earth. i used Flex lcd.

But no problem with another code .ASM
asm used pic16f873A

Plz some one help me where is the bugs.
but am Sure hardware is no problem.

My program running with open place(with out connecting enclosure)


Compiler: 4.140
Device: PIC16f1825
LCD: 16X2 JHD162
Lcd driver: Flexlcd

Code:

#include <inci100plus.h>
#include<math.h>
#include <flexlcd.c>
int msec,secc,minn=0;
#use FIXED_IO( A_outputs=PIN_A5,PIN_A4 )


#int_TIMER1                         //timer 1
void  TIMER1_isr(void)
{
msec++;
if(msec==8)
{
msec=0;
secc++;
write_eeprom(5, secc);
if(secc==59)
{
secc=0;
minn--;
write_eeprom(6, minn);
if(minn==0)
{
minn=0;
}
}
}
}



void main()
{
   
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_4); 
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);
   
   
   
   lcd_init();          //initialize lcd
Lcd_gotoxy(1,1);
printf(lcd_putc,"    Hello");
Lcd_gotoxy(1,2);
printf(lcd_putc,"   hai");
delay_ms(3000);
lcd_gotoxy(1,1)  ;
printf(lcd_putc," \f   heater",);
lcd_gotoxy(1,2)  ;
printf(lcd_putc,"  100 PLUS",);
Delay_ms(3000);
   
   
   
   
   while(TRUE)
   {
   
    lcd_gotoxy(1,1)  ;
    printf(lcd_putc," \f*TIME LEFT40MIN*");
    Lcd_gotoxy(1,2);
    printf(lcd_putc," PRESS START");
    delay_ms(600);
    lcd_gotoxy(1,1)  ;
    printf(lcd_putc," \f*TIME LEFT40MIN*");
    Lcd_gotoxy(1,2);
    printf(lcd_putc," INCERT waste ");
    delay_ms(600);
   
    if(input(pin_A0))
    {
    delay_ms(100);
Secc=0; minn=40;
delay_ms(500);

while(1)
   {
   lcd_gotoxy(1,1) ;
   printf(lcd_putc," \f PROCESSING.");
   lcd_gotoxy(1,2)  ;
   printf(lcd_putc,"TIME LEFT:%02dm",minn);
   delay_ms(500);
   lcd_gotoxy(1,1) ;
   printf(lcd_putc," \f PROCESSING..");
   lcd_gotoxy(1,2)  ;
   printf(lcd_putc,"TIME LEFT:%02dm",minn);
   delay_ms(500);
   lcd_gotoxy(1,1) ;
   printf(lcd_putc," \f PROCESSING...");
   lcd_gotoxy(1,2)  ;
   printf(lcd_putc,"TIME LEFT:%02dm",minn);
   delay_ms(500);

   if((minn<=40)&&(minn>=25))    //output  shutdown
    {
     //write_eeprom(5,minn);
     output_high(Pin_A5);
     delay_ms(1000);
     output_high(Pin_A4);
    }

else if((minn<=25)&&(minn>=20))
{
output_low(pin_A5);
output_high(pin_A4);
//write_eeprom(5,10);
}
else if((minn<=20)&&(minn>=10))
{
output_high(Pin_A5);
output_high(Pin_A4);
}
else if((minn<=10)&&(minn>=5))
{
output_low(Pin_A5);
output_high(Pin_A4);
}
else if((minn<=5)&&(minn>=1))
{
output_high(Pin_A5);
output_high(Pin_A4);
}
else if(minn<1)
{
output_low(Pin_A5);
delay_ms(1000);
output_low(Pin_A4);

delay_ms(250);
break;

}
   
   }
}
   }
   
}



But no problem with ASM (i dont know asm code)

list p = 16f873

#include "P16f873a.INC"

__CONFIG _LVP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC & _CP_ALL

; RCO- RS
; RC1-ENABLE

; Total Time: 10.0m
;Off:010s On:010s

;Time Left:10.0m
;ready........
;Insert Napkin and Press Start




;GENERAL PURPOSE REGISTER DEFINITIONS
;***** VARIABLE DEFINITIONS
;""""""""""""""""""" dont use common variables"""""""""""""""""""""""""""""""""""""
ADDRESS EQU 0x7B
VALUE EQU 0x7C
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU 0x7E ; variable used for context saving
pclath_temp EQU 0x7F ; variable used for context saving

;"""""""""""""""""""global variables"""""""""""""""""""""""""""""""""""""""""

delay_var1 equ 0x28
delay_var2 equ 0x29
mi_timer equ 0x2A
count_2 equ 0x2B
ge_timer equ 0x2C
GE equ 0x2D
timer equ 0x2E
LCD_TEMP equ 0x2F
address_location equ 0x30
loopcount equ 0x31

re_timer equ 0x34
total_time_1 equ 0x35
total_time_2 equ 0x36
on_time_1 equ 0x37
on_time_2 equ 0x38
off_time_1 equ 0x39
off_time_2 equ 0x3A
count_1 equ 0x3B
sec_1 equ 0x3C
sec_2 equ 0x3D
compare_1 equ 0x3F
compare_2 equ 0x3E
sec_6 equ 0x40
sec6 equ 0x41
change_display equ 0x42
dis_logic equ 0x43
relay_2_timer equ 0x44
relay_count_1 equ 0x45
relay_count_2 equ 0x46
;***********local variables""""""""""""
digit1 equ 0x50
digit2 equ 0x51
digit3 equ 0x52
digit4 equ 0x53
digit5 equ 0x54
fun_pass_1 equ 0x55
fun_pass_2 equ 0x56
fun_pass_3 equ 0x57
fun_pass_4 equ 0x58
fun_pass_5 equ 0x59
fun_pass_6 equ 0x5A
fun_return_1 equ 0x5B
fun_return_2 equ 0x5C
fun_return_3 equ 0x5D
fun_return_4 equ 0x5E
fun_return_5 equ 0x5F
fun_return_6 equ 0x60



#define LCD_E PORTC,1 ; LCD Enable control line
;#define LCD_RW PORTA,1 ; LCD Read/Write control line
#define LCD_RS PORTC,0 ; LCD Register-Select control line
LCD_DATA EQU PORTB ; LCD data lines interface
LCD_DATA_TRIS EQU TRISB

;"""""""""""""""""""""""" bit defintion"""""""""""""""""""""

#define Relay_1 PORTC,2
#define Relay_2 PORTC,3
#define start PORTC,4
#define jumper PORTC,5

#define carry STATUS,C
#define zero STATUS,Z

#define disp_update GE,0 ; bit 1---in setting mode,0---in running mode

#define timer_on GE,2
#define one_coin GE,3
#define relay_update GE,4
#define relay_2_start GE,5
ORG 0
GOTO START

ORG 4
GOTO SERVICE

;""""""""""""""""""""""""""""""port initialization""""""""""""""""""""""""""""""""""""""
PORT_INITIATION

banksel TRISA
movlw 0x06
movwf ADCON1
MOVLW B'00001111'
MOVWF TRISA
MOVLW B'00000000'
MOVWF TRISB
MOVLW B'00110000'
MOVWF TRISC
CLRF STATUS
RETURN

;"""""""""""""""""""""""""""""""" timer0 interrupt inialization""""""""""""""""""""""""""""""""""""""
ini_timer0_intrrupt
banksel OPTION_REG
movlw b'01000111'
movwf OPTION_REG
banksel INTCON
movlw .178
movwf TMR0
bcf INTCON,T0IF
bcf INTCON,INTF
bsf INTCON,T0IE ; timer0 interrupt is enabled.
bcf INTCON,INTE
bcf INTCON,PEIE
bsf INTCON,GIE
RETURN

ascii_table
andlw B'00011111'
addwf PCL,1
retlw .48 ;0
retlw .49 ;1
retlw .50 ;2
retlw .51 ;3
retlw .52 ;4
retlw .53 ;5
retlw .54 ;6
retlw .55 ;7
retlw .56 ;8
retlw .57 ;9
retlw .32 ;space ;10
retlw .98 ;b 11
retlw .99 ;c 12
retlw .100 ;d 13
retlw .101 ;e 14
retlw .102 ;f 15
retlw .103 ;g 16
retlw .104 ;h 17
retlw .105 ;i 18
retlw .106 ;j 19
retlw .107 ;k 20
retlw .108 ;l 21
retlw .109 ;m 22
retlw .110 ;n 23
retlw .111 ;o 24
retlw .112 ;p 25
retlw .113 ;q 26
retlw .114 ;r 27
retlw .115 ;s 28
retlw .116 ;t 29
retlw .117 ;u 30
retlw .118 ;v 31
retlw .119 ;w 32
retlw .120 ;x 33
retlw .121 ;y 34
retlw .122 ;z 35
retlw .12 ; 36 form feed

;'''''''''''''''''''''''''''''''''''''''''''''''''''adc'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
INI_ADC
banksel ADCON1
movlw B'11000010'
movwf ADCON1
bsf ADCON1,ADFM ; right adjus
banksel ADCON0
bsf ADCON0,ADCS1
bsf ADCON0,ADCS0 ;11 FOR RC TIME
bsf ADCON0,ADON
clrf STATUS
RETURN


;"""""""""""""""""""""""""""""""""""""'clears ram locations""""""""""""""""""""""""""""""""""
clear_ram

clrf STATUS
movlw .32
movwf w_temp
ram_clear
movf w_temp,0
movwf FSR
clrf INDF
incf w_temp,1
movf w_temp,0
sublw .124
btfsc carry
goto ram_clear
bsf Relay_1
bsf Relay_2
bcf timer_on
movlw .0
movwf sec6
return



START

call PORT_INITIATION
call clear_ram
call ini_timer0_intrrupt
call INI_ADC
call memory_recal
call LCDINIT ; Initialize LCDisplay
call LCD_CLEAR

goto ROLL


;------------------------------------------------------------
;---------------INTERRUPT SERVISE ROUTING--------------------
SERVICE

movwf w_temp
movf STATUS,w
movwf status_temp
movf PCLATH,w
movwf pclath_temp

clrf STATUS

btfss INTCON,T0IF ;; if timer0 -int
goto pop_up
movlw .177
movwf TMR0
bcf INTCON,T0IF
incf timer,1
btfss start
call start_button
incf re_timer ,1
movf re_timer,0
sublw .5
btfss carry
call lcd_update
incf dis_logic,1
movf dis_logic,0
sublw .30
btfss carry
call display_logic

incf ge_timer,1
movf ge_timer,0
sublw .50
btfsc carry
goto pop_up
clrf ge_timer
comf change_display
btfsc relay_2_start
call timer_10_min
btfss timer_on
goto pop_up



btfss Relay_1
call on_timer

btfsc Relay_1
call off_timer


incf mi_timer,1
movf mi_timer,0
sublw .40
btfsc carry
goto pop_up
clrf mi_timer
movf sec6,1
btfss zero
goto poppy

movlw .5
movwf sec6
decf count_1,1
btfss zero
goto pop_up
movf count_2,1
btfsc zero
goto load_set_value
decf count_2,1
movlw .255
movwf count_1
goto pop_up
second_6_inc
incf sec_6,1
movf sec_6,0
sublw .5
btfsc carry
return
clrf sec_6
return

poppy
clrf sec6
goto pop_up
load_set_value
clrf sec_6
movlw .0
movwf sec6
bsf Relay_1
;bsf Relay_2
clrf relay_2_timer
bsf relay_2_start
bcf timer_on
movf total_time_1,0
movwf count_1
movf total_time_2,0
movwf count_2
movlw .88
movwf relay_count_1
movlw .2
movwf relay_count_2
goto pop_up
start_button
clrf sec_6
bcf relay_2_start
clrf sec6
bcf Relay_1
bcf Relay_2
bsf timer_on
movf total_time_1,0
movwf count_1
movf total_time_2,0
movwf count_2
clrf sec_1
clrf mi_timer
clrf sec_2
return
on_timer
incf sec_1,1
btfsc zero
incf sec_2,1

movf sec_1,0
movwf fun_pass_1
movf sec_2,0
movwf fun_pass_2
movf on_time_1,0
movwf compare_1
movf on_time_2,0
movwf compare_2
call compare
btfss relay_update
return
bsf Relay_1
clrf sec_1
clrf sec_2
return
off_timer
incf sec_1,1
btfsc zero
incf sec_2,1

movf sec_1,0
movwf fun_pass_1
movf sec_2,0
movwf fun_pass_2
movf off_time_1,0
movwf compare_1
movf off_time_2,0
movwf compare_2
call compare
btfss relay_update
return
bcf Relay_1
clrf sec_1
clrf sec_2
return
display_logic
call second_6_inc
clrf dis_logic
return

;"""""""""""""""""""""return this contant during isr return"""""""""""""""""""""""""""""""""""""""""""""""""""
pop_up
movf pclath_temp,w
movwf PCLATH
movf status_temp,w
movwf STATUS
swapf w_temp,f
swapf w_temp,w
retfie ; return from interrupt


lcd_update
bsf disp_update
clrf re_timer
return
;"""""""""""""""show values in computer""""""""""""""""""
LCD_DISP
;0000 01 I/D S
;call delay_100ms
; movlw 0x07
; movwf ADDRESS
; call LCDPUTCMD
; call delay_100ms

movlw 0x80
movwf ADDRESS
call LCDPUTCMD
call delay_100ms

movlw '*'
btfss Relay_1
btfss change_display,0
movlw ' '
call display_data
movlw 'T'
call display_data
movlw 'i'
call display_data
movlw 'm'
call display_data
movlw 'e'
call display_data
movlw ' '
call display_data
movlw 'L'
call display_data
movlw 'e'
call display_data
movlw 'f'
call display_data
movlw 't'
call display_data
movlw ':'
call display_data

movf count_1,0
movwf fun_pass_1
movf count_2,0
movwf fun_pass_2
call count_update
movf digit2,0
call ascii_table
call display_data
movf digit1,0
call ascii_table
call display_data
movlw '.'
call display_data
movf sec6,0
call ascii_table
call display_data
movlw 'm'
call display_data

;call delay_1000ms

btfsc timer_on
goto processing
;call delay_100ms
; movlw 0x18
; movwf ADDRESS
; call LCDPUTCMD
; call delay_100ms
btfss change_display,0
goto napkin

;call delay_100ms
movlw 0xC0
movwf ADDRESS
call LCDPUTCMD
;call delay_100ms


movlw ' '
call display_data
movlw 'P'
call display_data
movlw 'r'
call display_data
movlw 'e'
call display_data
movlw 's'
call display_data
movlw 's'
call display_data
movlw ' '
call display_data
movlw 'S'
call display_data
movlw 't'
call display_data
movlw 'a'
call display_data
movlw 'r'
call display_data
movlw 't'
call display_data
movlw '.'
call display_data
movlw '.'
call display_data
movlw '.'
call display_data
movlw ' '
call display_data
movlw ' '
call display_data
return
napkin

movlw 0xC0
movwf ADDRESS
call LCDPUTCMD
;call delay_100ms


movlw ' '
call display_data
movlw 'I'
call display_data
movlw 'n'
call display_data
movlw 's'
call display_data
movlw 'e'
call display_data
movlw 'r'
call display_data
movlw 't'
call display_data
movlw ' '
call display_data
movlw 'N'
call display_data
movlw 'a'
call display_data
movlw 'p'
call display_data
movlw 'k'
call display_data
movlw 'i'
call display_data
movlw 'n'
call display_data
movlw ' '
call display_data
movlw ' '
call display_data
movlw ' '
call display_data
return




processing
movlw 0xC0
movwf ADDRESS
call display_Address
movlw ' '
call display_data
movlw 'P'
call display_data
movlw 'r'
call display_data
movlw 'o'
call display_data
movlw 'c'
call display_data
movlw 'e'
call display_data
movlw 's'
call display_data
movlw 's'
call display_data
movlw 'i'
call display_data
movlw 'n'
call display_data
movlw 'g'
call display_data
movlw '.'
call display_data
movf sec_6,0
sublw .1
movlw '.'
btfsc carry
movlw ' '
call display_data
movf sec_6,0
sublw .2
movlw '.'
btfsc carry
movlw ' '
call display_data
movf sec_6,0
sublw .3
movlw '.'
btfsc carry
movlw ' '
call display_data
movf sec_6,0
sublw .4
movlw '.'
btfsc carry
movlw ' '
call display_data
movf sec_6,0
sublw .5
movlw '.'
btfsc carry
movlw ' '
call display_data
return
movlw '.'
btfss change_display,0
movlw ' '
call display_data
movlw '.'
btfss change_display,0
movlw ' '
call display_data
movlw '.'
btfss change_display,0
movlw ' '
call display_data
movlw ' '
call display_data
movlw ' '
call display_data
return


LCD_DISPLAY
clrf mi_timer
clrf sec_1
bsf Relay_1
bsf Relay_2
bcf timer_on
movlw 0x80
call display_Address
movlw 'T'
call display_data
movlw 'o'
call display_data
movlw 't'
call display_data
movlw 'a'
call display_data
movlw 'l'
call display_data
movlw ' '
call display_data
movlw 'T'
call display_data
movlw 'i'
call display_data
movlw 'm'
call display_data
movlw 'e'
call display_data
movlw ':'
call display_data
movlw B'11000101'
call adc_convertion
movf fun_return_1,0
movwf fun_pass_1
movf fun_return_2,0
movwf fun_pass_2
movlw .17
movwf fun_pass_4
call div24by16
movf fun_pass_1,0
movwf total_time_1
movwf count_1
movf fun_pass_2,0
movwf total_time_2
movwf count_2
call count_update
movf digit2,0
call ascii_table
call display_data
movf digit1,0
call ascii_table
call display_data
movlw '.'
call display_data
clrf sec6
movf sec6,0
call ascii_table
call display_data
movlw 'm'
call display_data
call delay_100ms



movlw 0xC0
movwf ADDRESS
call display_Address
movlw 'O'
call display_data
movlw 'f'
call display_data
movlw 'f'
call display_data
movlw ':'
call display_data
movlw B'11010101'
call adc_convertion
movf fun_return_1,0
movwf fun_pass_1
movf fun_return_2,0
movwf fun_pass_2
movlw .11
movwf fun_pass_4
call div24by16
call mul_10
movf fun_return_1,0
movwf fun_pass_1
movwf off_time_1
movf fun_return_2,0
movwf fun_pass_2
movwf off_time_2
call count_update
movf digit3,0
call ascii_table
call display_data
movf digit2,0
call ascii_table
call display_data
movf digit1,0
call ascii_table
call display_data
movlw 's'
call display_data
movlw ' '
call display_data


movlw 'O'
call display_data
movlw 'n'
call display_data
movlw ':'
call display_data
movlw B'11001101'
call adc_convertion
movf fun_return_1,0
movwf fun_pass_1
movf fun_return_2,0
movwf fun_pass_2
movlw .11
movwf fun_pass_4
call div24by16
call mul_10
movf fun_return_1,0
movwf fun_pass_1
movwf on_time_1
movf fun_return_2,0
movwf fun_pass_2
movwf on_time_2
call count_update

movf digit3,0
call ascii_table
call display_data
movf digit2,0
call ascii_table
call display_data
movf digit1,0
call ascii_table
call display_data
movlw 's'
call display_data
return

division_16
movlw .4
movwf fun_return_5
div_16
bcf carry
rlf fun_pass_1,1
rlf fun_pass_2,1
decfsz fun_return_5,1
goto div_16
return
division_2
movlw .1
movwf fun_return_5
div_2
bcf carry
rrf fun_pass_2,1
rrf fun_pass_1,1
decfsz fun_return_5,1
goto div_2
return

;===========CONTROL DURING OPERATION==========================

ROLL

btfss disp_update
goto ROLL
bcf disp_update
btfss jumper
call LCD_DISPLAY
btfsc jumper
call LCD_DISP
goto ROLL




timer_10_min
decf relay_count_1,1
btfss zero
return
movf relay_count_2,1
btfsc zero
goto relay_off
decf relay_count_2,1
movlw .255
movwf relay_count_1
return
relay_off
bsf Relay_2
bcf relay_2_start
return


compare



movf fun_pass_2,0
subwf compare_2,0 ;;compare_2>fun_pass_byte2

btfss STATUS,C
goto _relay_on
btfss STATUS,Z
goto _relay_off
movf fun_pass_1,0
subwf compare_1 ,0
btfss STATUS,C
goto _relay_on
btfss STATUS,Z
goto _relay_off
_relay_on
bsf relay_update
return

_relay_off

bcf relay_update
return

memory_recal
movlw B'11000101'
call adc_convertion
movf fun_return_1,0
movwf fun_pass_1
movf fun_return_2,0
movwf fun_pass_2
movlw .17
movwf fun_pass_4
call div24by16
movf fun_pass_1,0
movwf total_time_1
movwf count_1
movf fun_pass_2,0
movwf total_time_2
movwf count_2

movlw B'11010101'
call adc_convertion
movf fun_return_1,0
movwf fun_pass_1
movf fun_return_2,0
movwf fun_pass_2
movlw .11
movwf fun_pass_4
call div24by16
call mul_10
movf fun_return_1,0

movwf off_time_1
movf fun_return_2,0

movwf off_time_2

movlw B'11001101'
call adc_convertion
movf fun_return_1,0
movwf fun_pass_1
movf fun_return_2,0
movwf fun_pass_2
movlw .11
movwf fun_pass_4
call div24by16
call mul_10
movf fun_return_1,0

movwf on_time_1
movf fun_return_2,0
movwf on_time_2
return

;"""""""""""This function for 24bit/16 division""""""""""""""""""""""""
div24by16
;""""""""""DIVIDEND"""""""""
;dividend fun_pass_3:fun_pass_2:fun_pass_1
;divisor fun_pass_5:fun_pass_4
;quotient fun_pass_3:fun_pass_2:fun_pass_1
;remainder fun_return_2:fun_return_1

clrf fun_pass_3
;call division_16

clrf fun_pass_5
CLRF fun_return_2
CLRF fun_return_1
MOVLW .24
MOVWF loopcount

LOOPU2416

RLF fun_pass_1, W ;shift dividend left to move next bit to remainder
RLF fun_pass_2, F ;
RLF fun_pass_3, F ;
RLF fun_return_1, F ;shift carry (next dividend bit) into remainder
RLF fun_return_2, F
RLF fun_pass_1, F ;finish shifting the dividend and save carry in fun_pass_1.0,
;since remainder can be 17 bit long in some cases
;(e.g. 0x800000/0xFFFF). This bit will also serve
;as the next result bit.

MOVF fun_pass_4, W ;substract divisor from 16-bit remainder
SUBWF fun_return_1, F ;
MOVF fun_pass_5, W ;
BTFSS carry ;
INCFSZ fun_pass_5, W ;
SUBWF fun_return_2, F ;

;here we also need to take into account the 17th bit of remainder, which
;is in fun_pass_1.0. If we don't have a borrow after subtracting from lower
;16 bits of remainder, then there is no borrow regardless of 17th bit
;value. But, if we have the borrow, then that will depend on 17th bit
;value. If it is 1, then no final borrow will occur. If it is 0, borrow
;will occur. These values match the borrow flag polarity.

SKPNC ;if no borrow after 16 bit subtraction
BSF fun_pass_1, 0 ;then there is no borrow in result. Overwrite
;fun_pass_1.0 with 1 to indicate no
;borrow.
;if borrow did occur, fun_pass_1.0 already
;holds the final borrow value (0-borrow,
;1-no borrow)

BTFSC fun_pass_1, 0 ;if no borrow after 17-bit subtraction
GOTO UOK46LL ;skip remainder restoration.

ADDWF fun_return_2, F ;restore higher byte of remainder. (w
;contains the value subtracted from it
;previously)
MOVF fun_pass_4, W ;restore lower byte of remainder
ADDWF fun_return_1, F ;

UOK46LL
DECFSZ loopcount, f ;decrement counter
GOTO LOOPU2416 ;and repeat the loop if not zero.
RETURN



;""""""""""""""""""""""""""""""""multiplay by 10 """"""""""""""""""""""""""""""""""""""""""""""""""""""""
;this will consume 2000 instruction cycles
mul_10
clrf fun_return_1
clrf fun_return_2
clrf fun_return_3
clrf fun_return_4
bcf carry
rlf fun_pass_1,1
rlf fun_pass_2,1
movf fun_pass_1,0
movwf fun_return_1
movf fun_pass_2,0
movwf fun_return_2
bcf carry
rlf fun_pass_1,1
rlf fun_pass_2,1
rlf fun_pass_1,1
rlf fun_pass_2,1
movf fun_pass_1,0
addwf fun_return_1,1
btfsc carry
incf fun_return_2,1
movf fun_pass_2,0
addwf fun_return_2,1
btfsc carry
incf fun_return_3,1
return










;"""""""""""""""""""LCD_INIT """""""""""""""""""""""""""""""""
LCDINIT
bcf LCD_RS
bcf LCD_E
call delay_100ms
call delay_100ms
; call delay_100ms
; call delay_100ms
; call delay_100ms

movlw .2
movwf LCD_DATA
bsf LCD_E
nop
nop
bcf LCD_E
call delay_100ms
movlw .2
movwf LCD_DATA
bsf LCD_E
nop
nop
bcf LCD_E
call delay_100ms
movlw .2
movwf LCD_DATA
bsf LCD_E
nop
nop
bcf LCD_E
call delay_100ms
;001DL N F XX
movlw 0x38
movwf ADDRESS
call LCDPUTCMD

;00001DCB
call delay_100ms
movlw 0x0C
movwf ADDRESS
call LCDPUTCMD
;0000 01 I/D S
call delay_100ms
movlw 0x06

_________________
Samuel.M
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Apr 28, 2014 5:34 am     Reply with quote

possible problem...
Quote:
enable_interrupts(GLOBAL);

lcd_init(); //initialize lcd

You should add a delay_ms(500); before the lcd_init(); line. This small delay allows the LCD module to properly power up before the PIC tries to access it.
Code:

enable_interrupts(GLOBAL);

delay_ms(500); //small delay allows LCD module to get 'organized'
lcd_init(); //initialize lcd

also
delete the use fixed_io(..); line.
unless you're very clever, let the compiler control the PROPER setup of the I/O pins.

also

I'm not 'happy' about the eeprom code in the ISR. Writing to the same EEPROM address can wear it out,also it take too much time in the ISR. Others will explain better.

hth
jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group