Every Triangular pulse is disturb.

Code:
' chip - PIC18F4620               

@ __CONFIG    _CONFIG1H, _OSC_HSPLL_1H  
                                                                                                                     
@ __CONFIG    _CONFIG3H,  _PBADEN_OFF_3H & _MCLRE_ON_3H  
                                                        
DEFINE OSC 40
INCLUDE "modedefs.bas"
include "My_EasyPIC4_LCD.bas"

                            
DEFINE ADC_BITS 10  
DEFINE ADC_CLOCK 2 
                                                                                                                              
ADCON0 = %00001111  
ADCON1 = %00001011  
                                                                                   
                                 
B0 VAR WORD
B1 VAR WORD
B2 VAR WORD
B3 VAR WORD
B4 VAR WORD
B5 VAR WORD
B6 VAR WORD

C0 VAR BYTE
C1 VAR BYTE


PAUSE 1000
   
LCDOUT $FE,1                      
PAUSE 1000                         
TRISB=$00  
                         
        
TRISD=%11110000                'Bits-4,5,6,7 Inputs, & Bits-3,2,1,0 Outputs of PORTD
        
        
Keyscane:  
         LCDOUT $FE, 1                                  
         LCDOUT "Scanning"                                                                           
        
        IF PORTD.4 = 1 THEN SquareWave                        
        IF PORTD.5 = 1 THEN TriangularWave             
        IF PORTD.5 = 1 THEN SineWave                  
        
        GOTO Keyscane


        
SineWave:   IF PORTD.5 = 1 THEN SineWave              'Wait for release button

	    TRISD=$00                                 'Make PortD an Output Port 
            LCDOUT $FE, 1                            
            LCDOUT "Sine-Wave"                          
            pause 200
                                                        
        
        
            C0=0                                            'Initialize the Sine Angle
Init_Sine:  TRISD=$00                                       'PortD an Output Port
 
            PORTD=((((SIN C0)+127)/10)*5)+50            '(+127) Removes the Negative Values
                                                        'Ampitude (Peak Value) = 1/2 of 5/10
                                                        'of the Maximum Output Voltage
                                                        '50 Represents the DC Offset
                                                        'DC Offset = 1/2 of 50/255
                                                        'of the Maximum Output Voltage
                                                        'The DC Offset is Measured between Zero
                                                        'and the Negative Peak of the Sinewave.
                                                        'To Obtain the Maximum Value, Change
                                                        'Both the 5 and the 10 to a 1.
                                 
        pauseus 1                                       'Pause Allowed between Angle Changes
                                                        'This will create, approximately, 100 Hz 
        C0=C0+1                                         'Increments the Sine Angle by 1 out of 255
        
        GOTO Init_Sine

        
SquareWave:   IF PORTD.4 = 1 THEN SquareWave
	      TRISD=$00                                      
              LCDOUT $FE, 1                                    
              LCDOUT "Square-Wave"                          
              PAUSE 200
       
                                                     
                                                      
        
                                                              
Init_Square:  TRISD=$00                                 'PortD an Output Port
              PORTD=0                                   'Square-Wave at PortD
                                                        'Starting with Decimal 0 out of 255
                                                        'of the Maximum Output Voltage.
                 
               PAUSEUS 2                                'The Smallest PAUSE Allowed is 5 micro-seconds. 
                  				        
                                                       
                                                        
                                                       
							'approximately 46KHz.           
               PORTD=255
               PAUSEUS 2
        
               GOTO Init_Square
        
TriangularWave:   IF PORTD.5 = 1 THEN TriangularWave
		  TRISD=$00                                      
                  LCDOUT $FE, 1                                  
                  LCDOUT "Triangle-Wave"                       
                  PAUSE 500
       
                                                        
                                                     
        
                                                               
Init_Triangluar:  TRISD=$00                             'PortD an Output Port
                  PORTD=0                               'Triangle-Wave at PortD
                                                        'Starting with Decimal 0 out of 255
                                                        'of the Maximum Output Voltage.
                                                    
                   PAUSE 1                              'The Smallest PAUSE Allowed is 1 micro-second.
                         		                '10 micro-seconds, in 1 micro-second steps,
                                                        
                                                        
                                                        
						        'approximately, 40KHz.
        PORTD=25                       
        PAUSEUS 1                      
        PORTD=50                       
        PAUSEUS 1
        PORTD=75
        PAUSEUS 1
        PORTD=100
        PAUSEUS 1
        PORTD=125
        PAUSEUS 1
        PORTD=150
        PAUSEUS 1
        PORTD=175
        PAUSEUS 1
        PORTD=200
        PAUSEUS 1
        PORTD=225
        PAUSEUS 1
        PORTD=255
        PAUSEUS 1
        PORTD=225
        PAUSEUS 1
        PORTD=200
        PAUSEUS 1
        PORTD=175
        PAUSEUS 1
        PORTD=150
        PAUSEUS 1
        PORTD=125
        PAUSEUS 1
        PORTD=100
        PAUSEUS 1
        PORTD=75
        PAUSEUS 1
        PORTD=50
        PAUSEUS 1
        PORTD=25
        
        GOTO Init_Triangluar
             
        END
.