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 CCS Technical Support

Problems with PIC16F767

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



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

Problems with PIC16F767
PostPosted: Sun Mar 04, 2007 2:09 pm     Reply with quote

Hi, i�m just starting to work with PICs microcontrolers. I�m using the PIC16F767, but i�m having some problems that i dont undrestand. I'm trying to comunicate this PIC with a computer using the serial port. And doing this using the serial interruption. But the interruption just doesnt work.

What�s happening???
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 04, 2007 2:21 pm     Reply with quote

First test a simple RS-232 character echo program that doesn't use
interrupts, like the one here:
http://www.ccsinfo.com/forum/viewtopic.php?t=22131&highlight=16f767&start=1
Does that work ?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Mar 04, 2007 4:05 pm     Reply with quote

Quote:

I'm trying to comunicate this PIC with a computer using the serial port.
And doing this using the serial interruption. But the interruption just doesnt work.

What�s happening???

How do you expect that we know what�s happening if we didn�t see a single line of code
nor any other info of your project.


Humberto
simoes.lc



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 05, 2007 7:33 am     Reply with quote

Well, i alread tested this routine and dont receive any answer. I alread tested the max232, connecting the RX with the TX pins and its working normaly.

#include <16F767.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

void main()
{
char c;

while(1)
{
c = getc();
putc(c);
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 05, 2007 9:43 am     Reply with quote

Post your compiler version.
simoes.lc



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 05, 2007 9:55 am     Reply with quote

version CCS 4.023
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Mar 05, 2007 9:59 am     Reply with quote

1)Does your circuit is alive?
2)If you are using a 4000000 Mhz crystal, #FUSES should be XT

Try this code:

Code:

#define LED PIN_xx // !!! Select a pin to connect a LED

void main()
{
char c;
   delay_ms(100); // Time to charge the capacitors in the MAX232
   output_toggle(LED);
   delay_ms(300); // The LED must toggle after power up !!!
   output_toggle(LED);

   printf("Test in progress...\r\n");

 while(1)
  {
   c = getc();
   putc(c);
   output_toggle(LED);
   delay_ms(200);
   output_toggle(LED);
  }
}


a) If the LED do not blink after power up, the PIC is not running at all.

b) If the LED blink once at power up but never blink after send a char, the program
is stuck in getc() waiting for a char that never come. You have a problem un Rx side.

c) If the LED blink after receive a char, but you doesn�t get any response,
you have a problem in Tx side.


Humberto
simoes.lc



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 05, 2007 10:28 am     Reply with quote

Well I tryed to use the up code and nothing happend, but when I comment the line

Code:
   printf("Test in progress...\r\n");


The program starts to work, waiting to the first character. When reaceive it, start to send it and dont stoping to wait the next character.
simoes.lc



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 05, 2007 12:44 pm     Reply with quote

but this code work right

Code:

#include <16F767.h>
#fuses XT,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7)
#use standard_io(B)
void main()
{
while(true)
{
output_high(PIN_B3);
delay_ms(500);
output_low(PIN_B3);
delay_ms(500);
putc('c');

}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 05, 2007 1:08 pm     Reply with quote

I compiled the code in post #4, and I don't see any problems in the
.LST file. Since transmit works ( putc('c') ), I think you may have
a hardware problem with the receive side. Look at the wire between
the PC's transmit pin and the receive pin on the MAX232. Make sure
the wire is connected to the correct pins. Also, the MAX232 has two
receiver sections in it. Make sure you are using the same receiver
section on the PC side and the PIC side of the MAX232.
simoes.lc



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 05, 2007 1:57 pm     Reply with quote

I tried again the code in post #4, but now i changed the max232 that i was using. And I got the same for both. The microcontroller waits the first character, get it e then starts to send it by tx and don�t stop for wait the next characters.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 05, 2007 2:20 pm     Reply with quote

I don't have a 16F767, so I compiled the program in post #4 for
a 16F877A with compiler vs. 4.023. I tested it on a PicDem2-Plus
board. It works. I can type characters in a terminal window on
my PC, and the PIC echoes them back.

I then compiled the program for the 16F767 and compared the .LST
file with the 16F877A. They are very similar. There's just a little
difference in the setup of the ADCON1 register, but that's because
the 16F767 has slightly different settings.

So I think you have a hardware problem. Something is not connected
correctly. You may be missing one or more capacitors on the MAX232
chip. Or, a connection could be missing somewhere. I can't really do
any more on this. You have to check the hardware.
simoes.lc



Joined: 04 Mar 2007
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 05, 2007 2:55 pm     Reply with quote

Well, to test this i make the following:

1. In the same breadboard a mount another microcontroller, the PIC16F628A.
2. Put almost the same code on it
3. Make it Run

And then it works perfet. Now I just don't know what to do.
Another thing that i didn't undrestand, looking at the same code for both PICs the size of then are very diferent, the size of the code for the 16f767 is bigger then the other one. Is it became the compiler is using software RS232? How can i force my compiler to use hardware RS232?

Thanks for the help given until now.
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