|
|
View previous topic :: View next topic |
Author |
Message |
john Goss Guest
|
Handy Firmware Revision trick |
Posted: Sun Jan 26, 2003 7:20 pm |
|
|
In my code, I store a constant set of charactors near the very end of ROM memory that contains the current rev of code I am working on. When the program resets or turns on, it prints out my current firmware revision on the RS232 port.
I keep this at the top of main() so when I make a change to the code, I quickly update the rev. number too.
Code: |
// Include header files for functions
#include <16f872.h> // Register definitions for PIC16F872 microcontroller
#include <stdio.h> // Standard I/O - provided by CCS
#include <stdlib.h> // Standard library functions - provided by CCS
#include <string.h> // String Functions - provided by CCS
#include <mod.h> // Port Pin Declarations, Function Prototypes, global variables for this program
//-----------------------------------------------------------------------------
// Do CCS C-Compiler directives
//-----------------------------------------------------------------------------
#use delay(clock=3686400)
#fuses XT,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT, NOLVP
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
//=====================================================
// !! UPDATE FIRMWARE REVISION HERE !!
//=====================================================
#org 0x07F0, 0x07FF
const char Revision[] = {"Rev 0.04"};
//=====================================================
//******************************************************
//* *
//* M M AAA IIIII N N *
//* MM MM A A I NN N *
//* M M M AAAAA I N N N *
//* M M A A I N NN *
//* M M A A IIIII N N *
//* *
//*****************************************************
void
main(void)
{
//---------- Occurs once on Reset or Power up ---------------------------------
printf("Reset\n\r");
printf("Rev: \%S\n\r",Revision);
|
___________________________
This message was ported from CCS's old forum
Original Post ID: 11018 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Handy Firmware Revision trick |
Posted: Mon Jan 27, 2003 1:49 pm |
|
|
Quote: | In my code, I store a constant set of charactors near the very end of ROM memory that contains the current rev of code I am working on. When the program resets or turns on, it prints out my current firmware revision on the RS232 port.
I keep this at the top of main() so when I make a change to the code, I quickly update the rev. number too.
//---------- Occurs once on Reset or Power up
printf("Reset\n\r");
printf("Rev: \%S\n\r",Revision);
|
That's a good idea. I came up with a variation that
would make it be more automatic. The code displays
the following text in the terminal window:
Build: 27-Jan-03 11:44:17
Code: |
#include "c:\program files\picc\devices\16F877.h"
#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
#use Delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
// I have the position backed off by 256 bytes from
// the end of ROM, because I'm using a bootloader there.
#org 0x1EE0, 0x1EEF
const char Build_Date[] = __DATE__;
#org 0x1EF0, 0x1EFF
const char Build_Time[] = __TIME__;
//=============================================
main()
{
printf("Build: \%s \%s\n\r", Build_Date, Build_Time);
while(1);
}
|
___________________________
This message was ported from CCS's old forum
Original Post ID: 11046
Last edited by PCM programmer on Mon Sep 14, 2009 12:09 pm; edited 1 time in total |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: Handy Firmware Revision trick |
Posted: Mon Jan 27, 2003 4:50 pm |
|
|
Does this statement substitute the actual date of compile or do you have to enter it with each compile?
#org 0x1EE0, 0x1EEF const char Build_Date[] = __DATE__;
___________________________
This message was ported from CCS's old forum
Original Post ID: 11055 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Handy Firmware Revision trick |
Posted: Mon Jan 27, 2003 4:57 pm |
|
|
Quote: | Does this statement substitute the actual date of compile or do you have to enter it with each compile?
#org 0x1EE0, 0x1EEF const char Build_Date[] = __DATE__;
|
The compiler gets the date from the operating system
(Win98, etc.) and inserts it as a string, in place of __DATE__.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11056
Last edited by PCM programmer on Mon Sep 14, 2009 12:10 pm; edited 1 time in total |
|
|
Sergio Guest
|
Re: Handy Firmware Revision trick |
Posted: Mon Jan 27, 2003 10:10 pm |
|
|
Clever.
Thanks.
:=---------------------------------------------------------
:=
:=That's a good idea. I came up with a variation that
:=would make it be more automatic. The code displays
:=the following text in the terminal window:
:=
:=Build: 27-Jan-03 11:44:17
:=
:=//-------------------------------------
:=#include "c:\program files\picc\devices\16F877.h"
:=#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
:=#use Delay(clock=8000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
:=
:=// I have the position backed off by 256 bytes from
:=// the end of ROM, because I'm using a bootloader there.
:=#org 0x1EE0, 0x1EEF
:=const char Build_Date[] = __DATE__;
:=#org 0x1EF0, 0x1EFF
:=const char Build_Time[] = __TIME__;
:=
:=//===============================================
:=
:=main()
:={
:=printf("Build: \%s \%s\n\r", Build_Date, Build_Time);
:=
:=while(1);
:=}
:=
:=
:=
:=
:=--</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11063 |
|
|
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
Re: Handy Firmware Revision trick |
Posted: Wed Jan 29, 2003 2:21 am |
|
|
:=:=
:=:=Does this statement substitute the actual date of compile or do you have to enter it with each compile?
:=:=
:=:=#org 0x1EE0, 0x1EEF const char Build_Date[] = __DATE__;
:=--------------------------------------------------------
:=
:=The compiler gets the date from the operating system
:=(Win98, etc.) and inserts it as a string, in place of __DATE__.
Which version of the compiler did __TIME__ get included? My lowly v3.061 will do __DATE__ but not __TIME__.
Also what should __DEVICE__ return? I get Error[27] Expression must evaluate to a constant.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11088 |
|
|
|
|
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
|