I will post the code, because I think that might be issue here... I used another PIC from a previous project and its working ..
Code:INCLUDE "modedefs.bas" 'Includes supoprt for PicBasic language OSCCON = %01100000 '4 Mhz DEFINE OSC 4 CMCON = 7 : ADCON1 = 7 DEFINE LCD_DREG PORTB ' Set LCD Data port DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_RSREG PORTA ' Set LCD Register Select port DEFINE LCD_RSBIT 2 ' Set LCD Register Select bit DEFINE LCD_EREG PORTA ' Set LCD Enable port DEFINE LCD_EBIT 3 ' Set LCD Enable bit DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_LINES 2 ' Set number of lines on LCD DEFINE LCD_COMMANDUS 2500 DEFINE LCD_DATAUS 250 DEFINE CHAR_PACING 2000 pause 1500 ' Define ADCIN parameters Define ADC_BITS 10 ' Set number of bits in result Define ADC_CLOCK 3 ' Set clock source (3=rc) Define ADC_SAMPLEUS 50 ' Set sampling time in uS DEFINE CCP1_REG PORTB DEFINE CCP1_BIT 0 ANSEL = %00000010 ' set AN1 as analog, others to digital ADCON1 = %10000010 ' Set PORTA analog for ten bit ADC 'ADCON0 = %00000001 ' Configure and turn on A/D Module TRISB = %01000010 TRISA = %00000111 DutyCycle var word Frequency var word Mainloop: ADCON0.2 = 1 'Start Conversion pause 20 ADCIN 0, DutyCycle 'Read channel PORTA.0 Duty Cycle ADCIN 1, Frequency 'Read channel PORTA.1 Frequency Frequency = Frequency + 245 DutyCycle = DutyCycle/4 lcdout $FE,1, "DutyCycle: ", dec DutyCycle lcdout $FE,$C0, "Frequency: ", dec Frequency pause 100 HPWM 1,DutyCycle,Frequency 'channel, dutycycle, frequency pause 20 goto Mainloop END





Bookmarks