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

Programming 16f877a on the air
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
umutso



Joined: 23 Jan 2013
Posts: 39
Location: turkey

View user's profile Send private message MSN Messenger

Programming 16f877a on the air
PostPosted: Thu Feb 14, 2013 2:21 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 1:10 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Fri Feb 15, 2013 1:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 15, 2013 1:38 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Fri Feb 15, 2013 2:05 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 6:52 am     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 18, 2013 6:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 7:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 7:06 am     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 18, 2013 7:14 am     Reply with quote

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: 1322

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 7:36 am     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 18, 2013 7:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 7:52 am     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 18, 2013 7:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 8:03 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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