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

What is this?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lecutus



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

What is this?
PostPosted: Fri Sep 04, 2009 12:36 pm     Reply with quote

What is this? I trying some printf's to check on some behaviour and I got what I think is some hex stuff. Regardless I need to identify what ever it is. I don't think I asked for this.

First the unidentified:

[90] [C9] [C9] [C9] [C9] [C9] [C9] ) [CB] k [A5] [91] [95] [81]

The log format in which it was found

09/04/2009 09:36:57.406 --> while_cnt = 105
09/04/2009 09:36:57.406 --> while_cnt = 106
09/04/2009 09:36:57.406 --> while_cnt = 107
09/04/2009 09:36:57.406 --> while_cnt = 108
09/04/2009 09:36:57.421 --> while_cnt = 109
09/04/2009 09:36:57.421 --> wh [C9] [C9] [C9] [C9] [C9] [C9] [C9] ) [CB] k [A5] [91] [95] [81] main XXXXXX>>>>>>>>>>>>XXXX
09/04/2009 09:36:57.421 --> b4 pir1 = 00, tmr1if = 00
09/04/2009 09:36:57.421 --> afta pir1 = 00, tmr1if = 00
09/04/2009 09:36:57.421 --> just b4 read_E_data
09/04/2009 09:36:57.421 --> Id_Num= 5000 Engine=01 Trans=03
09/04/2009 09:36:57.437 --> while_cnt = 1
09/04/2009 09:36:57.453 --> while_cnt = 2
09/04/2009 09:36:57.453 --> while_cnt = 3

And the code that produced it:


Code:

void main()
{
     int1 va;
     int8 while_cnt=0;
     //line_feed();
     printf(".......inside main XXXXXX>>>>>>>>>>>>XXXX");     line_feed();
     
     set_tris_a(0xff);
     set_tris_c(0xBF);
     setup_timer_1(t1_internal|t1_div_by_8);  //setup timer #1
     can_init();                    //init can module
     setup_wdt(wdt_on);
     set_timer1(0xBDC);             //init timer #1
     printf("b4 pir1 = %x, tmr1if = %x ",pir1,tmr1if );  line_feed();
     bit_clear(pir1,tmr1if);
     printf("afta  pir1 = %x, tmr1if = %x ",pir1,tmr1if );  line_feed();
     printf("just b4 read_E_data");line_feed();
     read_e_data();  //reads stored values from eeprom
   //printf("just afta read_E_data");line_feed();
   
 while(TRUE)
  {
  //printf("ENTERING  >>>>>>>>>>>>>> , inside while (true)"); line_feed();
  va = bit_test(pir1,tmr1if);
  //printf("Bit_test = value = %x, pir1 = %x, tmr1if = %x ", va,pir1,tmr1if );  line_feed();
  while (!bit_test(pir1,tmr1if))    //sample j1939 rX for 100ms, original
     {
        printf("while_cnt = %u",++while_cnt);   line_feed();

        //printf("Bit_test = value = %x, pir1 = %x, tmr1if = %x ", va,pir1,tmr1if );  line_feed();
        ck_j1939_input();
        ck_rs232();
     }
    // printf("vvvvvvvvvvvvvvvvvvvvvv  tf_data_ok=%u , tf_send_232=%u",tf_data_ok,tf_send_232);line_feed();
  //tf_data_ok = true;
  if (tf_data_ok) {process_rs232();} //PROCESS RS232 IF DATA IS OK
    //tf_send_232 = true;
    if (tf_send_232)
         {rs232();}        //SEND DATA STRING AFTER ANALYZING RS232 COMMANDS
    // printf("^^^^^^^^^^^^^^^^^^^^^^  tf_data_ok=%u , tf_send_232=%u",tf_data_ok,tf_send_232);line_feed();
     loop_cnt++;
     ck_spn_fmi();
     if (loop_cnt>=3)          //send swi status every 300ms
      {
        get_swi_status();
        send_swi_status();
        loop_cnt=0;
      }

      set_timer1(0xBDC);           //init timer #1
      bit_clear(pir1,tmr1if);
  //printf("leaving <<<<<<< inside while (true)");
  //line_feed();
     
  }
  printf(".........LEAVING main <<<XXXXXXXXXXXX");  line_feed();
}



One other bit of info, the while_cnt goes to 255, starts over goes to 108 or 109, then the above happens. and the while_cnt starts over.

So what gives?

I using pic18f258, pcwhd 4.079

Thanks L.
Ttelmah
Guest







PostPosted: Fri Sep 04, 2009 2:44 pm     Reply with quote

I'd say your chip was doing a watchdog restart.
Depending on your fuses the serial line is going unconnected (floating) at the PIC pin, while it waits to ensure the oscillator has started, etc. etc..

Best Wishes
lecutus



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

Here's the preprocessor stuff
PostPosted: Fri Sep 04, 2009 3:46 pm     Reply with quote

The watchdog restart would make sense. The question remains, what is it that I'm looking at?

Below is the way the program is setup


Code:
#include <18F258.h>
#fuses HS,PROTECT,NOLVP,WDT32,nowdt
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

#include <can-18xxx8.c>
#byte pir1=0x0F9E
#define TMR1iF  0X00
#rom int 0xf00000={0x00,0x00,0x00,0x00}

#define offset_id 0x00
#define offset_e  0x02// original
#define offset_t  0x03// original

#include <stdlib.h>
#include <stdio.h>
#include <input.c>

 int8 swi_status=0,loop_cnt=0,/*tmp_port,*/conv_lok,req_gear;       //buffer counter
 int8 sel_gear,cur_gear,gear, fuel_psi,oil_psi,water;
 int buffer[8],rx_len,rxstat;
 int32 rx_id,rx_ad,hrs;
 int1 tf_lube_ovr=false/*tf_send_status=false, tf_eng_run=false*/;
 //int1 tf_psi_lo=false,tf_temp_hi=false;
 
 int16 rpm,outspeed,inspeed,pressure_out,lube_psi,lube_temp;
 int16 pressure_max,crpm,volts,injt_psi,spn/*rpm_pre,rpm_total=0,rpm_temp*/;
 float bpm;
 int8 rm_volts,rm_hrs,alr_pump,fmi, spn_count=0,fmi_count=0/*,rpm_cnt*/;
 //int32 spn_fmi;
 int8 k_char,x=0;
 int16 x_cnt;
 int1 tf_rs232=false,tf_data_ok=false,tf_send_can=false,tf_send_232=false;
 char s1[30];
 //int16 rpm_rs=740,ov_press_rs=7500,pump_id=0,id_num; //original
 int16 rpm_rs=900,ov_press_rs=750,pump_id=0,id_num;
 int8 swi_rs=0,gear_rs=129,cnt_send_can=0,engine=0,trans=0;[code][/code][code][/code]



Thanks
L.
asmboy



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

View user's profile Send private message AIM Address

PostPosted: Fri Sep 04, 2009 6:30 pm     Reply with quote

the WDT32 is in conflict with nobrownout
and it wins in the masking wars

try

#fuses HS,PROTECT,NOLVP,nowdt,brownout,BORV42,noprotect



this assumes you are using a 5V supply for brownout, safe starting

and noprotect - just for fun until you are for sure debugged

i might add that with a 20 mhz clock and 115200 baud - the compiler default is allowing a baud rate error of about 1.5%

which is clearly OK - as you are receiving data
but a better choice of oscillator would be say
19.6608mhz which is a standard tho not common - can oscillator value

it results in a dead on 0.0% error in baud rate
and is ideal for your baud
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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