View previous topic :: View next topic |
Author |
Message |
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
Programming 16f877a on the air |
Posted: Thu Feb 14, 2013 2:21 pm |
|
|
Hello all
I have a circuit with 16f877a integrated with a gprs modüle. Gprs modüle registers to my server on a certain port via tcp stack. Pic gets values and sends via GPRS network to my server. All fine. But I need to update my code on the chip sometimes. The chip has serial boot loader and it works wired. But don't know how to send new hex file over this GPRS network.
If you can help me on this it will be great.
Thanks in advance _________________ Umut Sonkurt |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Feb 15, 2013 1:10 pm |
|
|
Send the hexfile (after all, its just a collection of bytes) and save that to a local eeprom on the pic... have the bootloader load file saved in eeprom...
Make sure to include a checksum or something so that the bootloader only updates the code once its sure its got the correct and complete update file.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
|
Posted: Fri Feb 15, 2013 1:23 pm |
|
|
Thanks for your reply. Do you have a template or sample code to do so that I search the net but no luck. I m using ccs compiler.
Thanks _________________ Umut Sonkurt |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Feb 15, 2013 1:38 pm |
|
|
No, I dont, and i dont think anyone else here does for that matter...
but maybe if you posted some information or code others could join in and try to help or give you suggestions, reference a good application note or something...
details like what bootloader are you using? where did you get it? is it ccs provided? is it by other known parties? can you post the bootloading code?
can you send data to the pic via GPRS? even a single byte? how?
do you have local storage on your pic board to buffer the incomming update hex file?
alot of things have to work right for your project to go right.
also, My personal opinion when i read:
Quote: | "im using CCS Compiler" |
... Which happens often, in those exact words.... i think something is "fishy"
you have tackled a GPRS program using TCP stacks on a 16f877a, which you say works. you MUST have a good PIC programing background to do this. i find it hard to believe that you can receive data but not send.
bootloading from EEPROM *should be easily achievable...
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
|
Posted: Fri Feb 15, 2013 2:05 pm |
|
|
I'm using boot loader program from microchip site. With pic boot loader sw from same site I can serially update my program on the pic.
I can also send and receive simple text strings via GPRS connection to a tcp listener over a socket connection.
Just can not send a program data via same GPRS connection to update the program in the pic. On this topic that's why I need help since I really do not know how to or where to start.
People are saying on the net upload your program to the internal EPROM and then load it to flash to use. That's it. I need a start point at least.
Thanks _________________ Umut Sonkurt |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Feb 18, 2013 6:52 am |
|
|
As a Starting point you should:
Locally, in your lab, load a HEX file to EEPROM.
Modify your bootloader to program the pic from EEPROM instead of UART serial data...
get it to work...
you should probably post your:
CCS Version
EEPROM chip#
PIC #
Post your Bootloader code (the one on the PIC) (preferably in CCS)
Make a _small_ test program that receives serial data and stores it to EEPROM... and then tries to flash the pic with the data on the EEPROM.
Post that on this forum... plenty more people will help you.
does your _remote_ board have onboard EEPROM? if it does not, its going to be alot harder...can you modify/add memory to your remote board?
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
|
Posted: Mon Feb 18, 2013 6:56 am |
|
|
Hi Gabriel,
I m using 16F877A which has a 256 bytes of internal eprom.So I m planning to use this area instead of an external one. I will also port the bootloader code in a few minutes. _________________ Umut Sonkurt |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Feb 18, 2013 7:04 am |
|
|
Quote: | I m using 16F877A which has a 256 bytes of internal eprom.So I m planning to use this area instead of an external one. |
From the Datasheet:
Quote: | Up to 8K x 14 words of Flash Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM),
Up to 256 x 8 bytes of EEPROM Data Memory |
Please explain how you intend to save 8K x 14 words worth of posible program size in 256 x 8 bytes?
http://i3.kym-cdn.com/entries/icons/original/000/006/707/nothing-to-do-here-template.jpg.scaled500.jpg
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Feb 18, 2013 7:06 am |
|
|
For a fail-safe remote update, the complete binary image must stored in an intermediate storage. The on-chip EEPROM is surely not sufficient for this purpose.
Alternatively, the GPRS modem control must be implemented in the bootloader, too. Usually, the memory size available for the bootloader won't allow it. |
|
|
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
|
Posted: Mon Feb 18, 2013 7:14 am |
|
|
Let me explain;
the GPRS board is a seperate secondary board which can operate seperately and manageed also seperately. My 16F877A only sleeps and awakens certain time periods and contacting a 5V relay which Powers up the GPRS modem and the modem connects opens the socket to the TCP server seperately. WHen it connects my 16F877A awaits the connected state and when got, it triggers my sensor and gets the result of the measurement andsends the result via UART via MAX232 to the gprs modem so to the tcp server accross.
So my controller only ;
sleep
awaken
contact the 5V relay to power up the modem
waits for the connect state
triggers the sensor
gets the result
sends the result to UART
Sleep again
thats it. So there is no GPRS ommunication codes or plenty of codes inside since GPRS modem is a seperate board.
Thats why I intend to use the internal eeprom on my chip so that I can update just a very tiny code sometime in the controller. Actually I only need to change the sleep and awake timing delays thats it.
Do I have to put an external storage still? _________________ Umut Sonkurt |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1355
|
|
Posted: Mon Feb 18, 2013 7:36 am |
|
|
Rather than try and store the whole code and reprogram it, why not simply have a program send over new sleep and awake timing delays and store those to the EEPROM, then have your code adapt based on those values? I think that will be easier in the long run and less risk for your project. |
|
|
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
|
Posted: Mon Feb 18, 2013 7:45 am |
|
|
Hello
this is actually a very nice idea. But I need a sample how can I do this and change. If you can provide me a very simple example code I can start and try it.
Thanks in advance, _________________ Umut Sonkurt |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Feb 18, 2013 7:52 am |
|
|
That my friend, is a and ENTIRELY different story.
you need to update a single parameter...
how do you control the sleep period?
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
umutso
Joined: 23 Jan 2013 Posts: 39 Location: turkey
|
|
Posted: Mon Feb 18, 2013 7:56 am |
|
|
I m using DS1302 real time clock. With RTC function every 4 hours, I get my tmr1 int and awake the system, do the job an sleep again t the next 4 hours. _________________ Umut Sonkurt |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Feb 18, 2013 8:03 am |
|
|
ok...
so your TMR1 triggers, your pic wakes, you get time from your RTC, check current time agains the "alarm Time" if it matches, you execute the sensor code, else you sleep again... right?
you only need to update your "alarm time" via GPRS...
if the Alarm time is a constant, save it instead in eeprom and update this value only... _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
|