Well, this might sound like a crazy problem but hopefully someone can help me out. So I'm writting code to interface with an XBEE chip and I couldn't get it to work. So as a bit of a sanity check I decided to turn on a LED(RA1) just to make sure the chip was actually running. To my complete surprise the LED will NOT turn on during the while loop, it seems the only code thats ever run is what is outside the while loop, is this a special thing with the HI-TECH compiler? First time I've used it so im not sure, heres my source.
C:
/*
* File: main.c
* Author: user
*
* Created on September 27, 2015, 10:05 AM
*/
#include <stdio.h>
#include <stdlib.h>
#include <pic16f628a.h>
#include <htc.h>
__CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & BOREN_ON & LVP_ON & CPD_OFF & CP_OFF);
#define ONESEC 125000
/*
*
*/
int main(int argc, char** argv) {
char id[] = {'a','b','c','d'};
// Pin and interrupt configuration
TRISB = 0x7; // all outputs except, RB0 - RB2
TRISA = 0x0; // all outputs
RA1 = 1;
INTCON = 0x10; // enabling INT(RB0) external interrupt, clearing flag
INTEDG = 1; // Configures RBO to interrupt on rising edge
RCIE = 1; // Rx interrupt enabled, interrupt when receiving data
RCIF = 0; // clearing flag
// USART configuration - hopefully this works correctly with xbee
BRGH = 1; // highspeed selected, desired 9600 actual 9615
SPBRG = 25; // baud rate = Fosc/16(SPBRG+1)
CSRC = 0; // Aynchronous mode, internal BRG
TXEN = 1; // Transmit enable
SYNC = 0; // Asynchronous mode.
SPEN = 1; // Enable serial comm
CREN = 1; // Continuous receive
// timer1 setup
T1CONbits.T1CKPS = 0b11; // 1:8 prescaler 125k = one second
TMR1ON = 1; // turn the timer on
while(1)
{
// transmit test...
//TXREG = id[0];
// anything in here doesn't work for some reason
}
return (EXIT_SUCCESS);
}