View previous topic :: View next topic |
Author |
Message |
jspencer
Joined: 22 Dec 2003 Posts: 57 Location: Boise, ID USA
|
16F688 Fails to start |
Posted: Fri Dec 16, 2005 4:37 pm |
|
|
I'm all of a sudden having some problems with the 16F688.
Here is the simple test code to see if the part is functioning. It does not blink the led's. Not sure why, but maybe there is something that I am missing. I've tried this on multiple parts that I knew to be working, and none of them now work.
Compiler: PCWH 3.239
Code: |
#include <16F688.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#use delay(clock=4000000)
void main() {
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
setup_oscillator(False);
while (TRUE){
output_high(PIN_C2);
output_low(PIN_C1);
delay_ms(1000);
output_low(PIN_C2);
output_high(PIN_C1);
delay_ms(1000);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 17, 2005 1:13 pm |
|
|
I don't have a 16F688, so I tested your program with 16F88, which
is similar. The LED started blinking when I commented out the
line shown in bold below:
Quote: | void main() {
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
// setup_oscillator(False); |
|
|
![](templates/subSilver/images/spacer.gif) |
jspencer
Joined: 22 Dec 2003 Posts: 57 Location: Boise, ID USA
|
|
Posted: Sat Dec 17, 2005 6:13 pm |
|
|
I actually narrowed it down, it is starting and running, but it is hanging on the first i2c_write call. Not sure why it stopped working all of a sudden. It has been working great for the last month, and now it just hangs on the call. Here is what I am testing with.
Code: |
#include <16F688.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES NOMCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //Reset when brownout detected
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOIESO //Internal External Switch Over mode enabled
#use delay(clock=4000000)
// I2C Clock and Data line declarations
#define I2C_SCL PIN_C4
#define I2C_SDA PIN_C3
#use i2c(master, sda=I2C_SDA, scl=I2C_SCL, fast)
// TCN75 i2c addresses
#define TCN75_I2C_WRITE_ADDR 0x90
#define TCN75_I2C_READ_ADDR 0x91
// TCN75 register addresses
#define TCN75_TEMP_REG_ADDR 0
#define TCN75_CONFIG_REG_ADDR 1
//#define TCN75_THYST_REG_ADDR 2
//#define TCN75_TSET_REG_ADDR 3
#define TCN75_SHUTDOWN_MODE 0x01
#define TCN75_ONE_SHOT_MODE 0x81
//#define TCN75_CONTINUOUS_MODE 0x00
#int_TIMER1
TIMER1_isr() {
}
//********************************************************************
// Initializes the TCN75
// Parameters: 0
// @ returns - nothing
//********************************************************************
void TCN75_init(void) {
output_float(I2C_SDA);
output_float(I2C_SCL);
}
//********************************************************************
// Sets up the TCN75 to be in one shot mode
// Parameters: 0
// @ returns - nothing
//********************************************************************
void setup_one_shot(void) {
i2c_start();
i2c_write(TCN75_I2C_WRITE_ADDR);
i2c_write(TCN75_CONFIG_REG_ADDR);
i2c_write(TCN75_SHUTDOWN_MODE);
//i2c_write(TCN75_CONTINUOUS_MODE);
i2c_stop();
output_high(PIN_C2);
delay_ms(500);
}
void init_routine() {
int i_cnt;
// initialization of features
port_a_pullups(FALSE);
setup_counters(RTCC_INTERNAL, FALSE);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_8|T1_CLK_OUT);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
TCN75_init();
enable_interrupts(INT_TIMER1);
//enable_interrupts(INT_EXT);
enable_interrupts(global);
// Sets up INT_EXT to watch for the rising edge
//ext_int_edge(L_TO_H);
SET_TRIS_A(0x04);
// A0 OUTPUT
// A1 OUTPUT
// A2 INPUT
// A3 OUTPUT
// A4 OUTPUT
// A5 OUTPUT
SET_TRIS_C(0x20);
// C0 OUTPUT
// C1 OUTPUT
// C2 OUTPUT
// C3 OUTPUT
// C4 OUTPUT
// C5 INPUT
// initial flashing sequence
}
void main() {
init_routine();
setup_one_shot();
while (TRUE){
output_high(PIN_C2);
output_low(PIN_C1);
delay_ms(500);
output_low(PIN_C2);
output_high(PIN_C1);
delay_ms(500);
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Dec 17, 2005 6:46 pm |
|
|
Quote: |
it is starting and running, but it is hanging on the first i2c_write call.
|
A never asked I2C question: What about the pull ups resistors ?
Quote: |
enable_interrupts(INT_TIMER1);
|
Do not enable a handler-less interrupt routine.
The datasheet in Section 3.5 SLAVE ADDRESS is quite confusing. Is refering that
"the four Most Significant Bits are fixed to 1001" BUT is refering to a
seven bits Register (??)(Table 3-1) namelly A6 A5 A4 and A3.
I guess it is wrong or at least a non consistent notation.
Humberto |
|
![](templates/subSilver/images/spacer.gif) |
jspencer
Joined: 22 Dec 2003 Posts: 57 Location: Boise, ID USA
|
|
Posted: Mon Dec 19, 2005 11:23 am |
|
|
Well, it turns out that the external EEPROM that we listed on our BOM is not what was used in making our PCA's. They used a rotated part (different pinout) instead of the one that was specified. Needless to say they will be making new PCA's with the right parts.
Thanks for the help. |
|
![](templates/subSilver/images/spacer.gif) |
|