![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
[Help] Bootloader Example CCS C don't work. |
Posted: Wed Oct 30, 2013 7:32 pm |
|
|
Hi all.
I have a trouble when try using bootloader of CCS.
I'm using CCS Ver 5.013, PIC16F877A to test it.
I compiled the (ex_bootload.c & ex_bootloader.c ) with change configs follow my hardware as below (for ex_bootload.c & ex_bootloader.c) with no errors:
*
Code: | #if defined(__PCM__)
#include <16F877A.h>
#fuses NOWDT
#use delay(crystal=10MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define PUSH_BUTTON PIN_A4
....
continue with original example code
|
Before, I tested ( ex_bootload.c & ex_bootloader.c) individual and it run OK.
Then, I used PIC KIT3 program ex_bootloader.hex into PIC16F877A, then using TeraTem (follow instructions on forum) to download ex_bootload.hex into PIC, it download file OK, but after I reset PIC, it not run true (count up and printf it to terminal).
Pls show me failure in my test, I'm begin learn with bootloader and have the first problems.
Thanks all. _________________ Begin Begin Begin !!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 30, 2013 8:44 pm |
|
|
What board are you using to test it ? Post the manufacturer and name
of the board, and post a link to the website for it so we can look at the
board's schematic.
Or, if you made the board, or breadboard circuit by yourself, then post
the schematic on an image hosting website such as
http://www.imageshack.us and post a link to the schematic here. |
|
![](templates/subSilver/images/spacer.gif) |
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
|
Posted: Thu Oct 31, 2013 3:01 am |
|
|
Thanks for your repply!
I'm made the board with schematic as bellow:
Thanks u ![Smile](images/smiles/icon_smile.gif) _________________ Begin Begin Begin !!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 01, 2013 11:34 am |
|
|
Your schematic shows jumper J6 to enable a pull-up on Pin A4. You need
to install that jumper. Pin A4 must have a pull-up on it so that the
switch (called J7) can work properly.
Also, I notice you have two jumpers called J6. Is that a mistake ?
Should one of them be called J5 ? |
|
![](templates/subSilver/images/spacer.gif) |
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
|
Posted: Sun Nov 03, 2013 8:54 pm |
|
|
Thanks u reply.
My schematic has error, which is double jumper J6, I copied it in Orcad Capture but it don't automatic change.
Yes, I enabled J6 ( jumper below connected with PortA), and enabled J7 to enter bootloader after reset.
I checked again my hardware is connect right follow instructions in exp code.
I don't know where errors excuted in my code.
I uploaded all project code on, Pls u check again for me, thanks u.
http://www.mediafire.com/download/kb95k2pcpeb13n2/bootloader_ccs.rar _________________ Begin Begin Begin !!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 04, 2013 2:35 pm |
|
|
I tested it, and the CCS bootloader example works on vs. 4.120 (from
the thread where I wrote my explanation). But it doesn't work with
vs. 5.013. I will try to find the problem.
I just compared the files between the two versions. CCS has made a
large number of changes. This will take a while.
I did some testing and vs. 5.013 works with the default PIC in
ex_bootloader.c which is the 16F887. So whatever changes CCS made,
they caused it not to work with a 16F877A. I'll try to find out why. |
|
![](templates/subSilver/images/spacer.gif) |
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
|
Posted: Mon Nov 04, 2013 6:48 pm |
|
|
Thanks u
I'm waiting from here to known what errors excuted in code.
.. _________________ Begin Begin Begin !!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 11, 2013 1:19 pm |
|
|
I found the problem. The bootloader doesn't work with the 16F877A with
vs. 5.013 because the program_memory_write() function is buggy. It also
fails with vs. 5.014. I'll wait for comments and then I'll report it to CCS.
Here is the test program:
Code: |
#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
// Set the Flash read/write address so it's in an unused
// area, above any running code.
#define ROM_ADDR 0x800
//====================================
void main(void)
{
int8 i;
int8 read_data[32] = {0};
int8 write_data[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
// Write to flash memory.
write_program_memory(ROM_ADDR, write_data, sizeof(write_data));
// Read it.
read_program_memory(ROM_ADDR, read_data, sizeof(read_data));
// Display the data read from Flash memory.
printf("Flash memory after being written: \n\r");
for(i = 0; i < sizeof(read_data); i++)
{
printf("%X ", read_data[i]);
if(((i+1) & 7) == 0)
printf("\n\r");
}
printf("\n\r");
printf("\n\r");
while(1);
} |
Here is the output in a TeraTerm window:
Quote: |
Flash memory after being written:
FF 3F FF 3F FF 3F 06 07
FF 3F FF 3F FF 3F 0E 0F
FF 3F FF 3F FF 3F 16 17
FF 3F FF 3F FF 3F 1E 1F
|
It only writes every 4th word. It should write them all.
Here is another display of the output. I read back the program memory
in MPLAB with the Programmer / Read menu. Then I looked at the
View / Program Memory window and it shows the same problem.
It's writing only every 4th word.
Code: |
Address Opcode
0800 3FFF
0801 3FFF
0802 3FFF
0803 0706
0804 3FFF
0805 3FFF
0806 3FFF
0807 0F0E
0808 3FFF
0809 3FFF
080A 3FFF
080B 1716
080C 3FFF
080D 3FFF
080E 3FFF
080F 1F1E
|
If I run the program on compiler vs. 4.120, I get the following output.
This is correct:
Code: |
Address Opcode
0800 0100
0801 0302
0802 0504
0803 0706
0804 0908
0805 0B0A
0806 0D0C
0807 0F0E
0808 1110
0809 1312
080A 1514
080B 1716
080C 1918
080D 1B1A
080E 1D1C
080F 1F1E |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Mon Nov 11, 2013 2:43 pm |
|
|
They seem to have destroyed the memory settings in the device database for several chips.
If you look at the thread about bootloader problems with the 16F1827:
<http://www.ccsinfo.com/forum/viewtopic.php?t=51450>
Here the chip had the memory type set in the database as 64/64, where it needs to be 16/64.
The same has happened with the 877, and the 877A, with the new compilers having the type set as 8/8, when it needs to be 2/2.
It seems to date from a few releases before the V5 compilers. I suspect they rewrote the tables when they added quite a few new chips at this point, and seem to have got a very large percentage of the settings wrong....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 11, 2013 2:53 pm |
|
|
Thanks. I wondered if that was it, but I couldn't check it because I only
have the command line compilers. I just now emailed CCS support and
referred them to this thread and especially to your comment at the end. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Tue Nov 12, 2013 4:27 am |
|
|
Can you verify that your compiler does actually say it is 5.014, 12940 in the listing?....
I've found something odd about the downloads.
I have 4.014, downloaded October 25th.
Lo and behold, look at the listing, and it says it is still 5.013.
Your code fails.
Just pulled a new copy of 5.014, and re-compiled, and your code runs.
This gives 5.014 in the listing.....
It looks as if they may initially put up a 5.014 download, that was actually 5.013. The CCSC file is exactly the same size, but version changes from 5.0.0.423 to 5.0.0.425
The new version still has the database error for the 16F1827.
Aargh..... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 12, 2013 10:41 am |
|
|
Starting with vs. 5, the compiler takes over version control. CCS has a
utility program called "Compiler Version" that you can access in Windows
by going to: Start button / Programs / PIC-C / Compiler version
If run it, and then click the "View other versions" button in the lower right
corner, it will list all versions installed in the c:\Program Files\PICC
directory. You can click on the version that you want to use and it will
be slightly highlighted in bold. Then click the Close Version List button
and then exit by clicking the X box in the upper right corner.
I don't like this feature because it's not always reliable for me. Sometimes,
if I want to revert to some vs. 4.xxx version, I have to open a Command
prompt window and manually wipe out most of the PICC directory.
(Everything except my .crg files, and the Projects folder). I really dislike
how the compiler takes over the version control. I used to be able to
reliably change the version just by re-installing the version I want.
Now, I can no longer trust it. This is a whole topic in itself, and maybe
deserves its own thread. My problems may be due to using the
command line compilers. You have the full IDE.
With regard to vs. 5.014, I downloaded it again just now (for command
line compilers pcm and pch) and did a binary file compare in a Command
prompt window with the files I downloaded on November 6, 2013. They
match. There are no differences.
I re-installed pcm vs. 5.014 and looked at the Compiler Version utility
and it says only vs. 5.014 is installed. That's as expected. I then compiled
and ran my test program in MPLAB vs. 8.91. It works in the MPSIM
simulator. That's unexpected. So I ran it on a PicDem2-Plus board
and it failed as noted in my previous post. Only the 4th word is written.
I don't normally use MPSIM to test hardware processes. I am a little
surprised that it works there. The .LST file shows vs. 5.014.
Are you testing in MPLAB simulator or in hardware ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 12, 2013 11:21 am |
|
|
CCS just emailed me and said they have fixed the problem with
write_program_memory() and it will be in the next release, vs. 5.015. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Wed Nov 13, 2013 5:23 am |
|
|
Just as an update to this, on the 16F1827 at least we can blame Microchip....
Their original data sheet for the chip has the settings 'right', but the current version lists the chip as having 32word write latches, not 8. However the example program correctly only writes 8....
Talk about making it easy.
CCS have said they have also corrected this one now.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 13, 2013 3:33 pm |
|
|
I installed the new version, vs. 5.015, and tested it with Exbootloader.c
with a 16F877A and it works.
It also works with my test program above. Both these tests were done
on a PicDem2-Plus board. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|