|
|
View previous topic :: View next topic |
Author |
Message |
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
PCD problems on reading port_B .. HELP PLEASE! |
Posted: Mon Sep 15, 2008 6:18 am |
|
|
Hi,
PCD 4.079
3FJ128GP706
PROBLEM:
I try to read the PORTB ( whole with "input_b()" or single pin with "input(pin_rb11) ")
The results is all zeroes.
This my trivial program:
Code: |
#include <33FJ128GP706.h>
#type unsigned
#Fuses NOWRTB,NOBSS,NOPROTECT
#Fuses NOWRT,PR_PLL,XT,NOCKSFSM
#Fuses NOOSCIO,NOWDT,NOWINDIS,WPRES128
#Fuses PUT128
#Fuses NODEBUG,NOCOE,NOJTAG
#define LED_ROSSO PIN_B10
#word PLLFBD=0x746
#word CLKDIV=0x744
#use delay(clock=77414400, restart_wdt)
#use rs232(BRGH1oK,baud=9600,UART2, ERRORS,RESTART_WDT)
void main(void)
{
PLLFBD=84; // M=75
CLKDIV=0b0000000000000000; // N1=2 N2=2
delay_ms(50);
output_high(LED_ROSSO);
gira:
restart_wdt();
delay_ms(100);
printf("\rRB->%lX - ",input_b());
printf("RG->%lX - ",input_g());
printf("RF->%lX",input_f());
output_toggle(LED_ROSSO);
goto gira;
}
|
The OUTPUT is:
"RB->0000 - RG->010E - RF->005E"
RG and RF follow the state of the inputs, RB is ALWAYS ZERO ..
What happens ???
Thanks in advance
Regards
Mauro |
|
|
glap Guest
|
|
Posted: Mon Sep 15, 2008 7:39 am |
|
|
Try to set the input port in digital mode (setup_adc_ports).
Bye
Gaetano |
|
|
Guest
|
|
Posted: Tue Sep 16, 2008 1:36 am |
|
|
thanks anyway , but still dont work ..
ragards |
|
|
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
|
Posted: Tue Sep 16, 2008 1:38 am |
|
|
thanks anyway , but still dont work ..
ragards |
|
|
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
|
Posted: Fri Sep 19, 2008 3:50 am |
|
|
Hi,
I found myself the solution!
The chip 33FJ128GP706 has TWO analog_to_digital modules, and then, we MUST declare:
setup_adc_ports(no_analogs); // useless, because the compiler produces itself the relative code
setup_adc_ports2(NO_ANALOGS); // this line mandatory
Putting this lines the portb work fine!
I write this to CCS:
....
This matter (two analog modules) is unclear in the microchip manual, and also in your manual.
Please explain this problem to all other developers.
I found this by ten trials.
Mauro |
|
|
|
|
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
|