View previous topic :: View next topic |
Author |
Message |
Guest
|
PIC RS232 and bootloader problems |
Posted: Mon May 05, 2008 4:39 pm |
|
|
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 !! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 05, 2008 4:54 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
hardik Guest
|
|
Posted: Mon May 05, 2008 5:11 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 05, 2008 5:13 pm |
|
|
Quote: | A 4Mhz Quartz Crystal. (Ref. QC 40.000 ) |
That sounds like 40 MHz.
My 4 MHz crystals have 4.00ECSH on the top. |
|
![](templates/subSilver/images/spacer.gif) |
hardik Guest
|
|
Posted: Mon May 05, 2008 5:24 pm |
|
|
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) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
hardik Guest
|
|
Posted: Mon May 05, 2008 5:32 pm |
|
|
It looks like the first one but quite bigger. |
|
![](templates/subSilver/images/spacer.gif) |
hardik Guest
|
|
Posted: Mon May 05, 2008 5:37 pm |
|
|
Edit: yes exactly like the second one :
"Another crystal in the HC-49 package" |
|
![](templates/subSilver/images/spacer.gif) |
hardik Guest
|
|
Posted: Tue May 06, 2008 8:29 am |
|
|
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.. |
|
![](templates/subSilver/images/spacer.gif) |
|