Problems with power up .. losing spi initialization
Posted: Tue Apr 19, 2005 10:27 pm
I've written a program using a pic16f819. For some reason everything everything works except on ocasion, the spi port is not initialized. When this happens the program functions normally but with no spi interface.
Here is a segment of my program. As you can see I've setup the spi port 3 times and the problem seems to get better by 70%. Has anybody seen this probem before.
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); setup_ccp1(CCP_COMPARE_INT); // Configure CCP1 to set
enable_interrupts(INT_CCP1);
set_timer1(0);
CCP_1=500;
setup_spi(SPI_SLAVE | SPI_H_TO_L | SPI_CLK_DIV_16);
enable_interrupts(INT_SSP);
enable_interrupts(GLOBAL); do
{
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Wed Apr 20, 2005 12:59 am
Sounds like a wacky problem. What's your version of the compiler ?
gator Guest
Posted: Thu Jan 24, 2008 9:39 pm
Has anybody else seen this problem? I am experiencing the same issue.
Sometimes the spi will not work on reset but everything else appears to function properly. Once the spi gets up and running though it works without any problems.
char DVD_BufferIn[BUFFER_SIZE];
char DVD_BufferOut[BUFFER_SIZE];
char Vault_Buffer[BUFFER_SIZE];
int DVD_counterIn;
int DVD_counterOut;
int Vault_counter;
int test_led_glow;
short int SPI_READ_DATA;
short int SPI_SEND_DATA;
byte SSPBUF_OUT;
byte DVD_response_is_ready;
byte DVD_message_started;
byte Vault_message_started;
byte tempcount;
byte reset_POR;
byte reset_BOR;
byte reset_TO;
byte reset_PD;
// ****************************************************************************
//
// main - main control loop
//
****************************************************************************
// process the new incoming data
if ( tempdata != ENQ )
{
switch ( tempdata )
{
case STX: Vault_Buffer[0] = STX;
Vault_counter = 1;
Vault_message_started = TRUE;
break;
case ETX: if ( Vault_message_started == TRUE )
{
Vault_Buffer[Vault_counter] = ETX;
for (i = 0; i <Vault_counter> 1 && Vault_counter > Vault_Buffer[1]) || Vault_counter >= (BUFFER_SIZE - 1) )
{
Vault_counter = 0;
Vault_message_started = FALSE;
for (i = 0; i <BUFFER_SIZE>= BUFFER_SIZE - 1 )
DVD_counterIn = 0;
}
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