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 RS232 and bootloader problems

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








PIC RS232 and bootloader problems
PostPosted: Mon May 05, 2008 4:39 pm     Reply with quote

Dear all..

First, I would like to note before narrating my story that I've scanned the forum for similar problems and have tried many suggested solutions but in vain.I'm stuck for five days now.

Here's my hardware :
MCU : 2 x PIC16F876-20/SP & 1 x PIC16F877-20/P
Crystal Clock : 4Mhz
Programmer : Elnec Pikprog
Compiler : PCW
RS232 Level shifter : MAX232


I'm facing two problems :

1- I can't get a bootloader to work :
I tried several PIC16F87x bootloaders (i.e : TinyBootloader - microchipc.com ). After loading the bootloader hex into the PIC using the pikprog programmer, the 'PIC downloader' is always displaying "Searching for bootloader". I manually reset the PIC (By connecting the MCLR pin to the mass) but nothing happens.

2 - After getting desperate from using a bootloader I've decided to begin coding my APP. And I soon realized that I can't establish a serial communication between the PIC and the PC :

I use this simple echoing program :

Code:
#include <16F876.h>
#device adc=8
#FUSES NOWDT, XT, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)

#int_RDA
void rda_isr(void)
{
char c;
c = getc();
putc(c);

}   

void main()
{

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
 
while(1);
}


I open hyperterminal, set the adequate configuration, and when I type on the keyboard I get different characters.For example when I type "a5vbekals" I get : "¢aê£b`M▀▐3". Even if I type the same character multiple times "ffffff" I get different characters : "f┘àf╥fª╦¶f".

The MAX232 is tested by looping it's Transmit and Receive PINs and it's working well.
I changed the PIC twice and tried with the PIC16F877. Same thing.

Any help would be greatly appreciated !!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 05, 2008 4:54 pm     Reply with quote

1. Do you have the terminal program configured for 9600,N,8,1 ?

2. What do you get back from the PIC if you type upper case 'U' characters ?

3. Are you using a 4 MHz crystal ? Or is it something else ?

4. Are you using a RS-232 cable between the PIC board and the PC ?
Or did you make it yourself ?

5. Is there a ground connection between the PIC board and the PC ?
Or is it just the Rx and Tx, without a ground wire ?


6. What's your compiler version ? You can find it at the top of the .LST
file, which is in your project directory. It's a number in this format 4.xxx
or 3.xxx, etc.
hardik
Guest







PostPosted: Mon May 05, 2008 5:11 pm     Reply with quote

Thank you for your hyper fast reply !

1- Yes.

2- Tomorrow I'll put some caps. (I'm at home now and the material is at school).

3- Yes. A 4Mhz Quartz Crystal. (Ref. QC 40.000 )

4- Yes I'm using an RS-232 cable Female/Female.

5- Of course the ground wire is there (DB9 used pins are : 2, 3 and 5 ).

6- 4.057

Thanks again.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 05, 2008 5:13 pm     Reply with quote

Quote:
A 4Mhz Quartz Crystal. (Ref. QC 40.000 )

That sounds like 40 MHz.
My 4 MHz crystals have 4.00ECSH on the top.
hardik
Guest







PostPosted: Mon May 05, 2008 5:24 pm     Reply with quote

Very probable !

The school technician claims that it's a 4MHz oscillator.
I'll verify it tomorrow.
How can I measure it ? (I'm sorry I'm still a beginner)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 05, 2008 5:28 pm     Reply with quote

Which one of these does it look like (or is similar to) ?

Here is a photo of a crystal in the HC-49US package
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/HC-49US.jpg
Another crystal in the HC-49 package:
http://rocky.digikey.com/weblib/ECS/Web%20Photos/HC-49U.jpg

Here is a photo of an oscillator.
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/ECS-TTL%20CLOCK%20OSCIL.jpg
hardik
Guest







PostPosted: Mon May 05, 2008 5:32 pm     Reply with quote

It looks like the first one but quite bigger.
hardik
Guest







PostPosted: Mon May 05, 2008 5:37 pm     Reply with quote

Edit: yes exactly like the second one :
"Another crystal in the HC-49 package"
hardik
Guest







PostPosted: Tue May 06, 2008 8:29 am     Reply with quote

Thank you Sir for your help !

It was a 40 Mhz not a 4 Mhz quartz.
What a tiny little problem causing to much of time waste ..

The bootloader and the serial communication are working 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