View previous topic :: View next topic |
Author |
Message |
JacquesB Guest
|
Problem controlling port A pin 6 |
Posted: Mon May 26, 2008 9:48 am |
|
|
Hi
I have a problem controlling port RA6 but I can control the rest of PORTA.
I think it comes from the configuration of the oscillator.
I've used the #fuse INTRC_IO and tried also INTRC without success.
I can control individual pin of the port except RA6 !
Processor used PIC18F2525 without an external clock or xtal.
void main(void)
{
setup_oscillator(OSC_4MHZ|OSC_INTRC); // set internal oscillator at 4 Mhz
set_tris_A(0x00); // set pins to output
set_tris_c(PORT_TRISC); // set pins input or output
port_b_pullups(true); //
output_A(0x00);
setup_adc_ports(NO_ANALOGS|VSS_VDD);//
setup_adc(ADC_OFF|ADC_TAD_MUL_0);//
setup_wdt(WDT_OFF);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
output_high(31749); // port Ra5 adress
output_high(31750); // port Ra6 adress
output_high(31751); // port Ra7 address
...
}
Does anybody knows what I'm doing wrong ?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 26, 2008 10:25 am |
|
|
Are you testing this on a hardware board or in a simulator ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 26, 2008 11:54 am |
|
|
You need to use a much more simple test program, and don't use use
magic numbers for the i/o pins. Use CCS pin constants in the .H file.
Example:
Code: |
#include <18F2525.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, NOLVP, NOPBADEN
#use delay(clock=4000000)
//==========================
void main()
{
while(1)
{
output_high(PIN_A6);
delay_ms(500);
output_low(PIN_A6);
delay_ms(500);
}
} |
|
|
|
JacquesB Guest
|
|
Posted: Mon May 26, 2008 11:55 am |
|
|
I'm testing it with the Pickit2.
The rest of the program works fine beside not being able to control RA6 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
JacquesB Guest
|
|
Posted: Mon May 26, 2008 12:20 pm |
|
|
The PIC18F2525 is monted on a PICDEM2 Plus board and it is running with the internal oscillator set to 4Mhz.
My program runs fine ( Rs232 interrupts, Timer 0 inetrrupts, SPI, ...) except for RA6 which stays low when I want to turn it ON. All other pins of PORTA can be controlled
I still think that the problem is related to the OSC1 OSC2 pins ( RA6 & RA7) that are normally used for an external cristal but I used the
#fuses INTRC_IO to make RA6&RA7 available as IO pins |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 26, 2008 12:40 pm |
|
|
What is your compiler version ? It's given at the start of the .LST file.
The .LST file is in your project directory. The compiler version is in
this format: x.xxx |
|
|
JacquesB Guest
|
|
Posted: Mon May 26, 2008 1:34 pm |
|
|
It is :
CCS PCH C Compiler, Version 4.071 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 26, 2008 1:45 pm |
|
|
That version should work.
Are you running a bootloader in the 18F2525 ? Are you certain that
the INTRC_IO fuse is really being programmed into the PIC ? |
|
|
jacquesB Guest
|
|
Posted: Wed May 28, 2008 8:51 am |
|
|
Sorry for the delay,
No there is no boot loader.
How can I be sure that the INTRC_IO is really being programmed ? |
|
|
|