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 CCS Technical Support

Any ideas on technique?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Jan 17, 2012 12:04 pm     Reply with quote

Well you can always take the pedestrian approach of wrapping every occurrence. The reason for this thread was to see if there were alternatives. I don't object this pedestrian approach of wrapping in fact I often do this for ordinary projects. Now and again projects have combinatorial complexity in which several devices in real time can and are in complex states. If issues arise I diagnose them with packet sniffers and tracing of the FSM states and stacks ( quasi Zigbee) of the multiple devices. There is a loss of immediacy with the printf but it doesn't affect this application since protocol stacks are dumped after a transceiver interrupt occurs and an error condition is detected.
Anyway the last post takes this thread back to square one so let me return to my original inquiry. Is there a better technique than the last post by asmboy suggests?
With respect I would prefer that that this thread have forward momentum. Anyone wishing to state their prowess ( number of complex projects they have done etc.) or their incredulity that others might do debugging this way is perfectly welcome to start their own thread.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jan 17, 2012 1:30 pm     Reply with quote

AGREED!!!! i would like a better simpler way too. And its clear that you have more potential territory to cover with adopting a uniform approach.

my background - for several years at the beginning -- was pure ASM for pic - mostly 28 pins or less - 16F/C parts. A late adopter of CCS was i - using free assembler in MPLAB etc

The primitive debug i showed , grew out of that ,and lazy moi, tagged along into ccs C programs. i've used the core of what i showed with various debug levels by the admittedly crude creation of debug1 debug2 etc - and the pedestrian use of search and replace in my text editor to manage the debug mess this could be viewed as. mostly it is a small load to bear.

that said - if managing a LOT of different - large code space program - does it not come down to strictly following/enforcing ONE of these methods uniformly? Being basically the only ( usually that is) programmer who benefits/suffers from my good/bad programming methods - what i do is simply the path of least resistance, NOT any brilliant insight, for sure.
Of course simpler yet appeals to me , if i could figure it out;-))
gribas



Joined: 21 Feb 2008
Posts: 21

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 3:37 pm     Reply with quote

Hi Douglas,

see if this works for you:

Code:

#include <18F4525.h>
#device adc=16               
#device PASS_STRINGS=IN_RAM   
#FUSES NOWDT, WDT128, HS, NOPROTECT, NOIESO, NOBROWNOUT, BORV21, NOPUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, RESERVED, NOPBADEN, NOLPT1OSC, MCLR

#use delay(clock=20000000)
#use rs232(baud=115200, xmit=pin_c6, rcv=pin_c7, stream = RS232) 
#case

#define DEBUG 1
#define DBG_STREAM RS232

#ifdef DEBUG
  #define TRACE(x) fprintf x 
#else
  #define TRACE(x)   
#endif


void main(){
   int8 variable_name_a = 10;
   int8 variable_name_b = 18;

   TRACE((DBG_STREAM,"Trace test\r\n"));

   if (10 == variable_name_a) {
        TRACE((DBG_STREAM,"Var A = %u, Var B = %u %s",
              variable_name_a,
              variable_name_b,
              "\r\n"
         ));
         
         variable_name_a = 11;
   }
 
}


The output is:
Trace test
Var A = 10, Var B = 18

if you comment out the #define debug line, you get rid of all the debug code:
Code:

.................... void main(){
0004:  CLRF   FF8
0006:  BCF    FD0.7
0008:  CLRF   FEA
000A:  CLRF   FE9
000C:  BSF    FB8.3
000E:  MOVLW  2A
0010:  MOVWF  FAF
0012:  MOVLW  00
0014:  MOVWF  FB0
0016:  MOVLW  A6
0018:  MOVWF  FAC
001A:  MOVLW  90
001C:  MOVWF  FAB
001E:  MOVF   FC1,W
0020:  ANDLW  C0
0022:  IORLW  0F
0024:  MOVWF  FC1
0026:  MOVLW  07
0028:  MOVWF  FB4
002A:  MOVLW  0A
002C:  MOVWF  05
002E:  MOVLW  12
0030:  MOVWF  06
....................    int variable_name_a = 10;
....................    int variable_name_b = 18;
.................... 
.................... 
....................    TRACE((DBG_STREAM,"Trace test\r\n"));
.................... 
.................... 
....................    if (10 == variable_name_a) {
0032:  MOVF   05,W
0034:  SUBLW  0A
0036:  BNZ   003C
....................         TRACE((DBG_STREAM,"Var A = %u, Var B = %u \r\n ",
....................               variable_name_a,
....................               variable_name_b 
....................          ));
....................           
....................          variable_name_a = 11;
0038:  MOVLW  0B
003A:  MOVWF  05
....................    }
....................   
.................... }
003C:  SLEEP



I tried some other alternatives here:
http://www.ccsinfo.com/forum/viewtopic.php?t=48943



Regards,
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 4:03 pm     Reply with quote

I really try to stay in the habit of making drivers that return error codes. That way, when an error code comes up, you can pass it to your error handler. You can make a verbose error handler or a non-verbose one, or a null one, changing it in debug mode.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Sep 03, 2012 4:00 pm     Reply with quote

Quote:

I really try to stay in the habit of making drivers that return error codes.


yes - i and others do that TOO, however what you describe is a feature meant also for the final release ( at least in my projects), as well as during hair tear-out/debug time.

But that is NOT the focus of the thread.

we have been bantering over the use of debug/scaffolding code methods used only in program construction, test and development - that is meant to be "deep 6'd" on release, as well as EZ ways to enable/disable the extra overhead.

Thanks for a good reminder just the same .
Very Happy
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 Previous  1, 2
Page 2 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