ycnr
Newbie level 5

Hi, I use 18 F 4550 to read 12 chanels analog values. I couldn't read values from portB. As you see i use PortE and PortB. I can read form PortE (except one pin) but i couldn't read any value from PortB. I tried many ways but i couldn't find the reason. is there anybody to help me.
...
...
...
similar codes for each channels


Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 #include <18f4550.h> #device ADC=10 #FUSES INTRC, NOWDT, NOLVP, PBADEN, NOBROWNOUT #use delay(clock=4Mhz) #include <lcd420_pc.c> float inpt,outpt; main(){ setup_oscillator(OSC_4MHZ); setup_psp(PSP_DISABLED); setup_comparator(NC_NC_NC_NC); setup_spi(SPI_SS_DISABLED); DISABLE_INTERRUPTS(GLOBAL); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_timer_3(T3_DISABLED|T3_DIV_BY_1); setup_CCP1(CCP_OFF); setup_CCP2(CCP_OFF); setup_vref(FALSE); setup_adc_ports(ALL_ANALOG); setup_adc(ADC_CLOCK_INTERNAL); set_tris_a(0xff); set_tris_b(0xff); set_tris_e(0xff); set_tris_c(0x00); set_tris_d(0x00); lcd_init(); delay_ms(10); while(true){ kanal_1: if(input(PIN_B7)==0) {while(true) {if(input(PIN_B7)==1) goto kanal_2;}} if(input(PIN_B6)==0) {while(true) {if(input(PIN_B6)==1) goto kanal_6;}} set_adc_channel(6); delay_us(10); inpt=read_adc()*0.00977517106549364613880742913001; output_c(0x00);output_bit(PIN_C0,1); set_adc_channel(0); delay_us(10); outpt=read_adc()*0.02346041055718475073313782991202; lcd_gotoxy(1,1); printf(lcd_putc,"1.IN=%3.1f",inpt); lcd_gotoxy(1,2); printf(lcd_putc,"1.OT=%3.1f",outpt); }
...
...
...
similar codes for each channels
Last edited by a moderator: