straw
Joined: 22 Apr 2009 Posts: 2
|
Dspic33FJ256GP710, digital input port B problem |
Posted: Wed Apr 22, 2009 8:20 pm |
|
|
In the previous testing with Dspic33FJ256GP710, I try to get digital inputs from all the ports and display the results through uart. As a results, I got all the available inputs except from port B. I had tried many methods but just failed. Is there any suggestion on this?
The code is shown as below:
Code: |
#include "33FJ256GP710.H"
#FUSES FRC_PLL,NOCKSFSM,NOOSCIO,NOPR,NOWDT
#byte TRISG = 0x02E4
#byte TRISF = 0x02DE
#byte TRISE = 0x02D8
#byte TRISD = 0x02D2
#byte TRISC = 0x02CC
#byte TRISB = 0x02C6
#byte TRISA = 0x02C0
#use standard_io(a)
#use standard_io(b)
#use standard_io(c)
#use standard_io(d)
#use standard_io(e)
#use standard_io(f)
#use standard_io(g)
#use delay(clock=40000000)
#use rs232 (baud=2400, xmit=PIN_F5, rcv=PIN_F4, parity=N, bits=8, stream=LCONF)
void set_io(void){
int16 value;
set_tris_a(0xffff);
set_tris_b(0xffff);
set_tris_c(0xffff);
set_tris_d(0xffff);
set_tris_e(0xffff);
// set_tris_f(0xffff);
set_tris_g(0xffff);
bit_clear (TRISF, 5); //LCONF TX
bit_set (TRISF, 4); //LCONF RX
fprintf(LCONF,"Check Port Status...\n");
value = get_tris_A();
fprintf(LCONF,"PortA: %lu\n ...",value);
value = get_tris_B();
fprintf(LCONF,"PortB: %lu\n ...",value);
value = get_tris_C();
fprintf(LCONF,"PortC: %lu\n ...",value);
value = get_tris_D();
fprintf(LCONF,"PortD: %lu\n ...",value);
value = get_tris_E();
fprintf(LCONF,"PortE: %lu\n ...",value);
value = get_tris_F();
fprintf(LCONF,"PortF: %lu\n ...",value);
value = get_tris_G();
fprintf(LCONF,"PortG: %lu\n ...",value);
}
#zero_ram
void main(void){
delay_ms(5000);
delay_ms(5000);
fprintf(LCONF,"Initialization. Please Wait...\n");
disable_interrupts(INTR_GLOBAL);
setup_oscillator(OSC_INTERNAL,40000000);
set_io();
enable_interrupts(INTR_NORMAL); //Enable global intrp
fprintf(LCONF,"Done...Start Up...\n");
while(1){
int16 data;
data = input_a();
printf("DataA: %lu\n",data);
data = input_b();
printf("DataB: %lu\n",data);
data = input_c();
printf("DataC: %lu\n",data);
data = input_d();
printf("DataD: %lu\n",data);
data = input_e();
printf("DataE: %lu\n",data);
data = input_f();
printf("DataF: %lu\n",data);
data = input_g();
printf("DataG: %lu\n",data);
delay_ms(2000);
}
} |
Is there any other configurations that I need to set? Please kindly advise. Thanks. |
|