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

Can't get my Write_eeprom to work.

 
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

Can't get my Write_eeprom to work.
PostPosted: Thu Aug 13, 2009 4:01 pm     Reply with quote

Yes it's me again, same program, different section.

This time I can't write the engine id or the transmission id to the eeprom.

the activity log:
08/13/2009 16:25:14.753 --> .......inside main XXXXXX>>>>>>>>>>>>XXXX

08/13/2009 16:25:14.769 --> id_num=e_data[0]=0,id_num=e_data[1]=0, engine=e_data[2]=0, trans=e_data[3]=0, count=5
08/13/2009 16:25:14.769 --> This from - read_e_data() Id_Num= 0000 Engine=00 Trans=00
08/13/2009 16:25:14.878 --> get_setup()>>>>>>>>>>>>>>>>>>>>>>>

08/13/2009 16:25:14.878 --> ID=1548
08/13/2009 16:25:18.472 --> Cat=01 Cummins=02 Detroit=03 Enter Engine Number=1

The line below is a printf to show if the variable engine recv'd the informatio

08/13/2009 16:25:20.347 --> engine=01

08/13/2009 16:25:20.347 --> Cat=01 Twin Disk=02 Allison=03 Enter Trans Number=3

The line below is a printf to show if the variable trans recv'd the informatio

08/13/2009 16:25:22.581 --> trans=03

Now starts the writing to the eeprom
08/13/2009 16:25:22.581 --> inside write_data()
08/13/2009 16:25:22.581 --> data_msb=6, data_lsb=12, offset=0, data =1548
08/13/2009 16:25:22.597 --> id_num=e_data[0]=12,id_num=e_data[1]=6, engine=e_data[2]=0, trans=e_data[3]=0, count=5
08/13/2009 16:25:22.597 --> This from - read_e_data() Id_Num= 1548 Engine=00 Trans=00
08/13/2009 16:25:22.597 --> write_eeprom_16bit - offset_id=0 ,id_num=1548
08/13/2009 16:25:22.613 --> write_eeprom - offset_e=4 ,engine=00
08/13/2009 16:25:22.613 --> write_eeprom - offset_t=5 ,trans=0
08/13/2009 16:25:22.628 --> LEAVING write_data()

these last statements are just reading the eeprom, verification

08/13/2009 16:25:22.628 --> This from - get_setup() Id_Num= 1548 Engine=00 Trans=00
08/13/2009 16:25:22.628 --> <<<<<<<<<<<<<<<<<<<<<<<<<<LEAVING get_setup()


08/13/2009 16:25:23.175 --> .......inside main XXXXXX>>>>>>>>>>>>XXXX

Now for the code in its entirety, I learned from last time:


Code:

//PROGRAM TO SEND SWITCH STATUS TO LOCAL CONTROL
//
//WAITS FOR REQUEST FROM LOCAL CONTROL
//    PGN300 IF LOCAL SWITCHES
//        BUFFER[0] SWI STATUS
//        BUFFER[1] PLUNGER LUBE AUTO/MAN
//     IF BUFFER[2,3] LESS THAN 0XFF THEN VALUE IS REQUESTED RPM
//     IF BUFFER[4,5] LESS THAN 0XFF THEN VALUE IS REQESTED OVER PRESSURE
//     IF BUFFER[6] LESS THAN 0XFF THEN VALUE IS REQESTED GEAR
//        BUFFER[7] NOT USED
//    PGN301 IF REMOTE SWITCHES
//
//
// 0=NO ACTIVITY
// 1=THROTTLE UP
// 2=THROTTLE DOWN
// 3=SHIFT UP
// 4=SHIFT DOWN
// 5=SET PRESSURE UP
// 6=SET PRESSURE DONW
// 7=START ENGINE
// 8=STOP ENGINE
// 9=E-STOP ENGINE
//10=NEUTRAL & IDLE ENGINE
//11=SPARE#1
//12=SPARE#2
// 01/30/07 clean up problem with momentary rpm going to 0000
//          missing break after spn detection
//01/20/09 eliminate the retrun of rpm/gear/ovp/swi
//         add E and T for eng and trans equiped
//01/31/09 add id to incoming string
//7.23.09 - added id parse routine id_num at the begining to keep truks other than the one
// that's suppose to have info
//7.31.09 - checking all routines for protocol, form, and definitions
//8.03.09 - From this date on there will be modification no tof the orignal plan
//8.13.09 - Reached out to CCS community for help. Going to save this as reference
//  still having conversion problems - X361 RS232 THRL_SHFT_ID.N.0803.2
//8.13.09 -  using X361 RS232 THRL_SHFT_ID.N.0813.09.1


#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

#define offset_e  0x04// original
#define offset_t  0x05

#include <stdlib.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_send_status=false,*/tf_lube_ovr=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;
 int8 swi_rs=0,gear_rs=125,cnt_send_can=0,engine=0,trans=0;

void line_feed()
{printf("\r\n");}



void read_e_data()   //reads stored values from eeprom
{
  int8 count=0,address=0;
  int8 e_data[4]; //original
 
  for(address=0; address<=4; ++address)
   {
   e_data[count++]=READ_EEPROM(address); } // LOADS E_DATA ARRAY, then feeds the parts
   printf(" id_num=e_data[0]=%u,id_num=e_data[1]=%u,  engine=e_data[2]=%u, trans=e_data[3]=%u, count=%u",e_data[0],e_data[1],e_data[2], e_data[3], count);
  line_feed();
  id_num=make16(e_data[1],e_data[0]);
   engine=e_data[2];
   trans=e_data[3];
   printf("This from - read_e_data() Id_Num= %04lu  Engine=%02u Trans=%02u",id_num,engine,trans);
   line_feed();
}


void write_eeprom_16bit(int offset, int16 data)
{
int8 i;
for (i=0;i<2;i++)
   {
      write_eeprom(i+offset,*((char *)&data + i));
      printf("i=%u, offset=%u, data =%lu",i, offset , data);
      line_feed();
      read_e_data();
   }
}

void write_eeprom_16bit_1(int offset, int16 data)
{     
int8 data_lsb, data_msb;
data_msb = make8(data,1); // gets msb of data
data_lsb = make8(data,0); // gets lsb of data

write_eeprom(offset, data_lsb);
write_eeprom(offset+1, data_msb);

printf("data_msb=%u, data_lsb=%u, offset=%u, data =%lu",data_msb, data_lsb, offset , data);
      line_feed();

read_e_data();
   
}

[b]The problem seems to be here/below, but I don't see it. And I still could be wrong. [/b]

void write_data()  //store operating prarmeters in eeprom
{
  printf(" inside  write_data()");
  line_feed();
   write_eeprom_16bit_1(offset_id,id_num);// this works
   //write_eeprom_16bit(offset_id,id_num); //this works too!!!!
   printf(" write_eeprom_16bit - offset_id=%u ,id_num=%lu ", offset_id,id_num);
  line_feed();
   
    write_eeprom(offset_e,engine);// orginal
    printf(" write_eeprom - offset_e=%u ,engine=%02u ", offset_e,engine);
    line_feed();
    write_eeprom(offset_t,trans);//original
    printf(" write_eeprom - offset_t=%u ,trans=%u ", offset_t,trans);
  line_feed();
  printf(" LEAVING write_data()");
  line_feed();
}

void get_setup()
{
printf("get_setup()>>>>>>>>>>>>>>>>>>>>>>>");
  line_feed();
  setup_wdt(wdt_off);
  line_feed();
  printf("ID=");    //enter id number for pumper
  id_num = get_long(); //orignal statement
 
  line_feed();
  printf("Cat=01 Cummins=02 Detroit=03 Enter Engine Number=");
  //printf("crap");
 
  engine = get_int();
  line_feed();
   printf("engine=%02u", engine);
  line_feed();
 
  printf("Cat=01 Twin Disk=02 Allison=03 Enter Trans Number=");
  trans = get_int();
  line_feed();
  printf("trans=%02u",trans);
 
  line_feed();
  write_data();//<<<<<<<<<<<<<<<<<<<<<<<<<<
  printf("This from - get_setup() Id_Num= %04lu  Engine=%02u Trans=%02u",id_num,engine,trans);
  line_feed();
  //setup_wdt(wdt_on);
  printf(" <<<<<<<<<<<<<<<<<<<<<<<<<<LEAVING get_setup()");
  line_feed();
  setup_wdt(wdt_on);
}



void get_input_232(char* s, int max)
 {
   int len;
   char c;
 printf("inside   get_input_232() >>>>>>>>>>>>>>>.........>>>>>>");
  line_feed();
   --max;
   len=0;
   do {restart_wdt();
     c=getc();
     if(c==8) {  // Backspace
        if(len>0) {
          len--;
          putc(c);
          putc(' ');
          putc(c);
        }
     } else if ((c>=' ')&&(c<='~'))
       if(len<max) {
         s[len++]=c;
         //putc(c);
       }
   } while(c!=38);
   s[len]=0;
 printf("LEAVING  get_input_232()<<<<<<<<<<<<<...........<<<<<<<<<<");
  line_feed();
}

 void ck_rs232()
   {
   //printf("inside   ck_rs232() >>>>>>");
  //line_feed();
    if (kbhit())
      {
       k_char=getc();
       if (k_char=='!')
        {
         tf_RS232=true;
         x=0;
         x_cnt=0;
         tf_data_ok=false;
         output_low(pin_b5);
        }
      if ((k_char=='i') | (k_char=='I')) get_setup(); // <<<<<<<<<<
      }
       if (tf_rs232)
        {
         get_input_232(s1, 30);
         tf_rs232=false;
         tf_data_ok=true;
         output_high(pin_B5);
         //x=0;while (x<24) {putc(s1[x]);x++;}
        }

 //printf("LEAVING   ck_rs232() <<<<<<<<<<");
  //line_feed();
   }
void process_rs232()
{
   char r[5],g[5],op[6],sw[5],id[5];// this also shows original order
   //char id[5],r[5],g[5],op[6],sw[5];
 int8 x1=0;
  tf_data_ok=false;
  x=0;x1=0; while (s1[x1]<0x3a)       
       { x1++;
         if (s1[x1]>0x2f)  {r[x]=s1[x1];x++;x1++;}   //get rpm string
       }
       r[x]=0; //add null to end of string
          x=0;x1++; while (s1[x1]<0x3a)
       {if (s1[x1]>0x2f) {g[x]=s1[x1];x++;x1++;} }//get gear string
       g[x]=0;   //add null to end of string
       x=0;x1++; while (s1[x1]<0x3a)
       {if (s1[x1]>0x2f) {op[x]=s1[x1];x++;x1++;}} //get over pressure string
       op[x]=0;    //add null to end of string
       x=0;x1++; while (s1[x1]<0x3a)
       {if (s1[x1]>0x2f) { sw[x]=s1[x1];x++;x1++;}} //get switch status string
       sw[x]=0;  //add null to end of string
        x=0;x1++; while (s1[x1]<0x3a)
      {if (s1[x1]>0x2f) {id[x]=s1[x1];x++;x1++;}}//get pump_id string
       id[x]=0;  //add null to end of string
    // putc(10);putc(13);
     //x=0;while (x<strlen(r)) {putc(r[x]);x++;} putc(10);putc(13);
     //x=0;while (x<strlen(g)) {putc(g[x]);x++;} putc(10);putc(13);
     //x=0;while (x<strlen(op)) {putc(op[x]);x++;} putc(10);putc(13);
     //x=0;while (x<strlen(sw)) {putc(sw[x]);x++;} putc(10);putc(13);
      // pump_id=atol(id);
       rpm_rs=atol(r);      //convert string to number
       gear_rs=atoi(g);
       ov_press_rs=atol(op);
       swi_rs=atoi(sw);
      pump_id=atol(id); // original place
     printf("RPM=%lu Gear=%u OP=%lu SWI=%u ID=%lu\r\n",rpm_rs,gear_rs,ov_press_rs,swi_rs,pump_id);
   if (pump_id==id_num)
       {tf_send_can=true;   //set true to send received command via j1939
       cnt_send_can=0;     //init number of times to send j1939 packet with 232 com.
       tf_send_232=true;}   //set true to return data string
       
   
}



void get_swi_status()
{  int8 port;
   swi_status=0;                       //assume all switches off
   tf_lube_ovr=0;                      //assume lube override=false
   port=input_a();
   delay_ms(1);
   if (!bit_test(port,0)) swi_status=1; //throttle up
   if (!bit_test(port,1)) swi_status=2; //throttle down
   if (!bit_test(port,2)) swi_status=3; //shift up
   if (!bit_test(port,3)) swi_status=4; //shift down
   if (!bit_test(port,4)) swi_status=5; //max up
   if (!bit_test(port,5)) swi_status=6; //max down
   port=input_c();
   delay_ms(1);
   if (!bit_test(port,0)) swi_status=7; //start
   if (!bit_test(port,1)) swi_status=8; //stop
   if (!bit_test(port,2)) swi_status=9; //e-stop
   if (!bit_test(port,3)) swi_status=10;//neutral/idle
   if (!bit_test(port,5)) tf_lube_ovr=true; //lube override=true;
}
void ck_j1939_input()
{int16 a;
//printf("inside  ck_j1939_input() >>>>>>");
  //line_feed();
 if (can_kbhit())
       {restart_wdt();
        can_getd(rx_id, &buffer[0],rx_len,rxstat);
        rx_ad=rx_id&0x000000Ff;       //get source address
        if (rx_ad==05) req_gear=buffer[2];   //if source address=05 buffer[2]=req_gear;
        if (rx_ad==44) {crpm=crpm=make16(buffer[2],buffer[1]); //store req spd buffer
                        crpm=crpm>>3;               //calculate speed received rpm/8
                       }
        rx_id=rx_id&0x00ffff00;  //mask out irrevllant data
        rx_id=rx_id>>8;          //shift data to right 8 times
        switch (rx_id)
         {case (61442) : {conv_lok=buffer[0] & 0x04;
                          outspeed=make16(buffer[2],buffer[1]);
                          outspeed=outspeed>>3;            //divide by 8
                          inspeed=make16(buffer[6],buffer[5]);
                          inspeed=inspeed>>3;              //divide by 8
                          }break;
         case (65226) : {fmi=buffer[4]&0x1f;
                         spn=buffer[2];
                         spn_count = 20;
                         fmi_count = 20;
                        }break;

         case (61444) : {*(&rpm)=buffer[3];
                         *(&rpm+1)=buffer[4];
                         }
                         break;                 //correct by dividing by 8
         case (61445) : {sel_gear=buffer[0];
                         cur_gear=buffer[3];}break;
         case (65271) : {volts=make16(buffer[5],buffer[4]);
                         rm_volts=(volts%20)>>1;volts=volts/20;
                         }break;

         case (65263) : {a=(long)buffer[3]*58;oil_psi=a/100;
                         a=(long)buffer[0]*58;fuel_psi=a/100;}break;
         case (65262) : {a=buffer[0]-40;
                         a=(long)a*9;
                         a=a/5;
                         water=a+32;}break;
         case (65253) : {hrs=make32(buffer[3],buffer[2],buffer[1],buffer[0]);
                         rm_hrs=(hrs%20)>>1;hrs=hrs/20;
                        }break;
         case(65143)  : {pressure_out=make16(buffer[1],buffer[0]);
                         lube_psi=make16(buffer[3],buffer[2]);
                         lube_temp=make16(buffer[5],buffer[4]);
                        }break;

         case(302)    : pressure_max=make16(buffer[1],buffer[0]);break;

         case(303)    :{alr_pump=buffer[0];
                        *(&bpm)=buffer[1];
                        *(&bpm+1)=buffer[2];
                        *(&bpm+2)=buffer[3];
                        *(&bpm+3)=buffer[4];
                        if (bpm>99) bpm=0;}break;
         case (65243) : {*(&injt_psi) =buffer[2];
                        *(&injt_psi+1)=buffer[3];
                        injt_psi = (injt_psi*58)/100;}
                        break;
         default :{//spn=0;
                 };
         }
       }
// printf("LEAVING   ck_j1939_input() <<<<<<<<<<");
//line_feed();
}

void RS232()
{
  printf("inside  RS232()>>>>>>");
  line_feed();
  output_low(pin_b4);
  printf("I%04lu",id_num);
  rpm=rpm>>3;                             //rpm
  printf("R%04lu",rpm);
  switch (cur_gear)                       //gear
  { case (124) : gear = 1; printf("G0%u", gear); break;
    case (125) : gear = 2; printf("G0%u", gear); break;
    case (126) : gear = 3; printf("G0%u", gear); break;
    case (127) : gear = 4; printf("G0%u", gear); break;
    case (128) : gear = 5; printf("G0%u", gear); break;
    case (129) : gear = 6; printf("G0%u", gear); break;
    case (130) : gear = 7; printf("G0%u", gear); break;
    case (131) : gear = 8; printf("G0%u", gear); break;
    case (132) : gear = 9; printf("G0%u", gear); break;
    case (133) : gear = 10; printf("G%u", gear); break;
    default    : {}; break;
  }
    //oil pressure
  printf("O%03u", oil_psi);
     //water temp
  printf("C%03u",water);
    //battery volts
  printf("V%02lu.%u", volts, rm_volts);
    //pump speed
  printf("W%04lu",outspeed);
    //fuel pressure
  printf("F%03u", fuel_psi);
    //convertor lock
  printf("L%u",conv_lok);
     //ov pressure set
  printf("S%05lu", pressure_max);
    //pump output pressure
  if (pressure_out>15000) pressure_out=15000;
  printf("P%05lu", pressure_out);
    //pump lube pressure
  printf("X%03lu", lube_psi);
    //pump lube temperature
  printf("Y%03lu", lube_temp);
     //barrels per min
  if (bpm<1) printf("B0%02.2f",bpm);
  if ((bpm>=1)&&(bpm<10)) printf("B0%2.2f",bpm);
  if (bpm>=10) printf("B%2.2f",bpm);
    //engine hrs
  printf("H%05lu", hrs);
  printf("E01T01");
    //diagnostics spn
  printf("D%04lu", spn);
    //diagnostics fmi
    printf("Z%04lu",pump_id);
  printf("_%02u", fmi);
  printf("!\r\n"); //delimiter
  tf_send_232=false;
  output_high(pin_b4);
  printf("LEAVING  RS232()<<<<<<<<<<");
  line_feed();
}

void send_swi_status()
{if (tf_send_can)       //if true send this data via
 {buffer[0]=swi_rs;     //swi status packet
 buffer[1]=0x00;
 buffer[2]=*(&rpm_rs);
 buffer[3]=*(&rpm_rs+1);
 buffer[4]=*(&ov_press_rs);
 buffer[5]=*(&ov_press_rs+1);
 buffer[6]=gear_rs;
 buffer[7]=0xff;
 }else                //else only send swi_status
 {buffer[0]=swi_status;
 buffer[1]=0x00;
 buffer[2]=0xff;
 buffer[3]=0xff;
 buffer[4]=0xff;
 buffer[5]=0xff;
 buffer[6]=0xff;
 buffer[7]=0xff;
 }
 if (tf_lube_ovr) buffer[1]=0x08; //bit4 buffer[1]=1 to override auto lube
 if (!input(pin_c4)) rx_id=300;  //remote swi interface C4=0
 if (input(pin_c4)) rx_id=301;   //local switch interface C4=1
 rx_id=rx_id<<8;
 can_putd(rx_id,&buffer[0],8,1,TRUE,FALSE);
 if (tf_send_can) cnt_send_can++;    //setup to end 232 data 3 times
 if (cnt_send_can==3) tf_send_can=false; //then revert to normal mode
}

void ck_spn_fmi()
{if (spn_count > 0) spn_count--; else spn = 0;
 if (fmi_count > 0) fmi_count--; else fmi = 99;
}

void main()
{
  int1 va;
  line_feed();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
  bit_clear(pir1,tmr1if);
 // 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 );
  /* printf("Bit_test = value = %2x ", bit_test(pir1,tmr1if));
  line_feed();
  printf(" pir1 = %x ", pir1);
  line_feed();
  printf("tmr1if = %x", tmr1if);
  */
  //line_feed();
  while (!bit_test(pir1,tmr1if))    //sample j1939 rX for 100ms
     {
     //printf("inside !bit_test pir1,tmr1if, inside while (true)");//line_feed();
     ck_j1939_input();
     ck_rs232();
     }
     if (tf_data_ok) process_rs232(); //PROCESS RS232 IF DATA IS OK
     if (tf_send_232) rs232();        //SEND DATA STRING AFTER ANALYZING RS232 COMMANDS
     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();
}




Once again, it's gonna be something simple. Blearyeyed I go into the long night.

Thnx
L.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 4:41 pm     Reply with quote

Your program is much too large. Cut out about 90% of it, re-test,
confirm that it still shows the problem, and post the short program.
Don't do a "code dump" on the forum. Trouble-shoot it yourself first.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Fri Aug 14, 2009 2:04 am     Reply with quote

Basically, in you write_data routine you call write_eeprom_16bit_1 to store the id_num.

In write_eeprom_16bit_1 you call read_e_data which overwrites the engine and trans value you have entered with the values stored in eeprom which are curently 0.
Smile

Now as for PCM programmer's comment, he is quite correct, it is good that you have posted a complete (although I havn't tried to compile it) program, it is quite large.
If you made a copy of your project and then stripped out all the bits you didn't need to try and trace the problem you may have caught this yourself. If not then you would have had a smaller piece of code to post which would make our life much easier.

Have fun.
lecutus



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

We have a winner
PostPosted: Fri Aug 14, 2009 8:19 am     Reply with quote

Mr Wayne_

You nailed it was the read, after looking in the context of a new day. Idea It was the second bug of a long day.


Yes to PCM ok next time I'll the minimum the info, yes it compiles, everything works. I end up not worrying about what works and work on the parts that don't.

And now that everything is working as it should and I have a better grasp of the architechture I'm dealing with. The rest of what I have to do is plain programming, yeah

So you won't hear from me for awhile.
Cool

Thanx
L.
asmboy



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

View user's profile Send private message AIM Address

a minor point but i see this all the time
PostPosted: Fri Aug 14, 2009 9:09 am     Reply with quote

one comment - perhaps it will help you

it is about the 115200 baud rate - we both know why you are using it .

i use that rate and higher but the 20mhz crystal is a bad choice for that particular baud with or without the BRG16 register settings

while the change i am suggesting to you will have an impact on your internal timer1 intialization count values - you can drive the baud error percentage to zero if you just change to a crystal of 18.432 mhz instead of 20mhz -and set your OSC statement , and timer 1 init values for rollover - in code to match

once you make that hardware and couple of lines software change -
then your baud error percentage will be 0.0%

this matters a lot especially at higher and higher baud rates - of which your code is a prime example


just my 2 cents
lecutus



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

Never say never
PostPosted: Fri Aug 14, 2009 9:15 am     Reply with quote

Never say never.

I'll take that into consideration, since we're still developing the hardware and software concurrently.

Great head up, that's why I like this place

Thanks
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