|
|
View previous topic :: View next topic |
Author |
Message |
nuwavedc
Joined: 06 Feb 2008 Posts: 17
|
PIC16F884 port initialization problem |
Posted: Wed Feb 06, 2008 2:20 pm |
|
|
****MYSTERY SOLVED****
Stupid hardware mistake. Used QFN pinout on a TQFP layout.
CCS PCM C Compiler, Version 4.025, PIC 16F884
For some reason no matter what I do I cannot get port C0 and port RA6 to output.
This has me stumped, and I am 99.9% sure this is not hardware related after 3 prototypes are exhibiting the same problem.
I am using fast IO statement on all of the ports to save some code space and controlling the tris registers manually (although letting the compiler set port direction by not using fast IO and tris statements does not help)
The remainder of my code is working perfectly. I am running a 3 digit LCD display, getting A/D samples, getting keypresses, sending a PWM to a beeper, sending a pwm to a backlight, etc. This is bizarre, its only Pins C0 and A6 that seem not to be setup correctly.
Code: | #inline
void HardwareInit(void)
{
setup_adc_ports(sAN0|sAN2|VSS_VREF);
setup_adc(ADC_CLOCK_DIV_32);
setup_spi(FALSE);
setup_wdt(WDT_18MS);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); //Rollover 32.768mS
setup_timer_2(T2_DIV_BY_4,255,1); //Rollover 0.51mS
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
setup_oscillator(OSC_8MHZ); //4 Mhz with div 4 prescaler
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
set_pwm1_duty(0);
set_pwm2_duty(0);
set_tris_e(0x00); //all port e pins are outputs
set_tris_d(0x00); //all port d pins are outputs
set_tris_c(0x00); //all port c pins are outputs
set_tris_b(0x07); //RB0,1,2 all inputs 1 = inputs, 0 = outputs
set_tris_a(0x0D); //RA0,2,3 are inputs
Port_b_pullups(0x07);
}
(from our setup.h)
#include <16F884.h>
#device adc=10
#use delay(clock=4000000)
#FUSES WDT //Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES PROTECT //Code protected from reads
#FUSES CPD //Data EEPROM Code Protected
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //No Debug mode for ICD
#FUSES WRT //Program memory write protected
#FUSES BORV40 //Brownout reset at 2.1V
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
//Interrupt priorities:
#priority timer2,timer1
|
_________________ Thanks,
NuWaveDC
Last edited by nuwavedc on Thu Feb 07, 2008 1:47 pm; edited 2 times in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 06, 2008 4:54 pm |
|
|
Make a simple test program that does nothing except toggle those pins.
Get rid of at least 90% of your code. Turn off the watchdog. Don't do
any code protection. Don't use fast i/o. Let the compiler handle the TRIS.
Don't enable interrupts (you have no interrupt service routine). Don't
enable or disable all those peripheral modules.
Here's an example of a test program:
http://www.ccsinfo.com/forum/viewtopic.php?t=32982&start=1 |
|
|
nuwavedc
Joined: 06 Feb 2008 Posts: 17
|
Probably Should Clarify... |
Posted: Thu Feb 07, 2008 9:38 am |
|
|
I will try a simplification as you suggested, but I probably should mention that the remainder of my code is working perfectly. I am running a 3 digit LCD display, getting A/D samples, getting keypresses, sending a PWM to a beeper, sending a pwm to a backlight, etc. This is bizarre, its only Pins C0 and A6 that seem not to be setup correctly. FYI there is an ISR in my ISR.C. Mainly wondering if anyone has run into similar circumstances _________________ Thanks,
NuWaveDC |
|
|
nuwavedc
Joined: 06 Feb 2008 Posts: 17
|
Solved |
Posted: Thu Feb 07, 2008 1:47 pm |
|
|
Stupid hardware mistake. Used QFN pinout on a TQFP layout. _________________ Thanks,
NuWaveDC |
|
|
|
|
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
|