CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

pic 16f876a int_rda no work on power up

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
krimenet



Joined: 16 Oct 2007
Posts: 2

View user's profile Send private message

pic 16f876a int_rda no work on power up
PostPosted: Tue Oct 16, 2007 5:15 am     Reply with quote

Please help me i'm new in this topics,
I have a problem:
when i start up the pic for the first time (on power up), the firmware not enable the int_rda, on the contrary if I reset it, int_rda is enable and firmware work right.
I have put in my code printf() instructions to monitorizing data received and I seen data input is 0 on start up, instead if I reset the data input is correct.
Please help me If you have any ideas.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Oct 16, 2007 5:23 am     Reply with quote

Have you tried adding the ERRORS directive to your #use rs232 line?

What is your compiler version?

Without example code I can't give more advise. Please post a small program demonstrating your problem, max 20 lines of code. Make sure the example is complete so we can copy/paste it into our compiler, this means including #fuses statements, etc.
krimenet



Joined: 16 Oct 2007
Posts: 2

View user's profile Send private message

PostPosted: Tue Oct 16, 2007 8:46 am     Reply with quote

ckielstra wrote:
Have you tried adding the ERRORS directive to your #use rs232 line?

What is your compiler version?

Without example code I can't give more advise. Please post a small program demonstrating your problem, max 20 lines of code. Make sure the example is complete so we can copy/paste it into our compiler, this means including #fuses statements, etc.


My compiler version is PCWH ver 3.203
below the code example:

#include <16F876a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT
#use delay(clock=20000000)
#use i2c (master,scl=PIN_C3,sda=PIN_C4,slow,force_hw)
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, stream=XBEE, ERRORS)
#use rs232(baud=38400, xmit=PIN_B1, rcv=PIN_B0, stream=COM, ERRORS)
#define DS1820_PIN PIN_A0
#define SRF02 0xe0
#define BUF_SIZE 10

typedef struct{

char head; // l'inizio del packet deve essere "@" 0X40 64
char command; //può essere S settaggio A avvio letture L lettura effettuata
char my; //nel caso S invia il my da modificare nel caso L my identifica l'indirizzo di chi trasmette
int16 data_1;
char tail; // la fine del packet deve essere [CR] (\r)
int ok;

}t_Packet;
t_Packet Packet = { 0x40, 0x41, 0x31, 0x32, 0x0D, TRUE }; // dummy initialize


static int I2C_Buffer [16];
int16 Distanza;
long int timer;
char data;
unsigned char t1_200ms=0;


// ============================================================================
// la comunicazione seriale riceve un interrupt handler
// ============================================================================
#int_rda
void Rs232c_Receive(void)
{
if( kbhit() ){
data=fgetc(XBEE);
if (data=='$')
fprintf(COM,"%u",data);
}

}

void main(void)
{

Packet.my=2;
Packet.command='L';
enable_interrupts( INT_RDA );
enable_interrupts( GLOBAL );
while(1)
{

}
}

Thanks for the answer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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