Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Find the bug

Status
Not open for further replies.

granddad

Well-Known Member
Most Helpful Member
Perhaps I should not be doing embedded.. took me >2 hours to find this
Code:
 for ( y = 0;y < 12;y++)
        {
    while (!U2STAbits.TRMT ) {}
       U1TXREG = filedata[y];
        }
    while (!U2STAbits.TRMT ) {}
    __delay_ms(500);
    LCD_setcursor(2,8);
    LCD_single_chr('I',0);
 
Comes from having too many UARTS ! , tested on one to an FTDI, moved to two to a HC-12.... (wireless thing )
 
I have just had one too..
C:
unsigned int ReadInt(unsigned int addr)
   {
   unsigned int ret=0;
   ret = ReadEeprom(addr) << 8;
   ret+= ReadEeprom(addr+1);
   return ret;   
   }

unsigned char ReadEeprom(unsigned int badd )
   {
   EEADR = (badd & 0x0ff);
     EECON1bits.CFGS = 0;
   EECON1bits.EEPGD = 0;
   EECON1bits.RD = 1;
   return ( EEDATA );  // return with read byte
   }

Quite literally.. nearly a day.... I need my eyes testing!!!
 
Happens all the time.
At least this is software.
On hardware though..........
I bet all of us at one point of time, have soldered a polarized component backwards.
 
lol ya, much easier to to fix chuncks of code then pcb's!
Im very happy to see this post, not due to the misfortunes , but because i was stuck on this one for 2 days:

Code:
void txPickit(unsigned char dat2,unsigned int baudrate)
{
  unsigned char ctr, dat = dat2;
  unsigned char ;      
  PORTC &= 0b11110111;    // start bit
  PORTC |= 0b00000111;   // leds off (pin C0 (only) still clears to 0 from previous instruction.... no idea why)
//  PORTCbits.RC3 = 0;
  delayBAUD(baudrate);      // start bit delay
  for (ctr = 0;ctr<8;ctr++)         // shift out
  {   
  if (dat & 1){PORTC |= 0b00001111; }else {PORTC &= 0b11110111;PORTC |= 0b00000111; }    // 
  dat/=2;         // shift right
  delayBAUD(baud);    // floops!
  }
  PORTC |= 0b00001111;   // stop bit
  delayBAUD(baudrate);  delayBAUD(baudrate); // stop bit delay
  delayBAUD(baudrate);  delayBAUD(baudrate);  

}

was starting to feel like a newb again, and its funny since i just applied for a job doing embeded(for a 3d printer & scanner company), I was starting to second guess myself... what do you guys think, you have seen some of my blunders and successes, think i can pull it off? , it would be alot more fun than my current job, chasing cars...literally! Maybe i should mail him back to see that I didn't get it!
 
that is my position too... also guilty of the cut and paste
 
Last edited:
Come to think of it I am more or less self taught on everything... I started computing with a US Navy Basic Electronics book back in the 70's (great book It had cartoon characters with the diagrams ), then I ran an electronics club after hours at my office, coding started with a “free” copy of Turbo Basic “ on a DIY. 286 PC. When I say everything I mean everything , Plumbing, Electrics, bricklaying, Photography, Music, Double Glazing, Book Keeping, Horticulture,Cooking all DIY. Only taught subject as a mature student, was Art, that is until some yobs burnt the college down .... Regret I never found time for a foreign language.
 
I bet all of us at one point of time, have soldered a polarized component backwards.
My big problem with hardware is forgetting to put the jack cover over the wire before soldering the wire onto the connector, like with phone plugs. Seems to happen constantly!
 
Nearly a day? Two days? Pffffftt!!!

I spent two weeks after making a small, tiny change to a big software project. Such a tiny change that I didn't bother to back up all the other important work added to the source code. It was originally working great, just needed one tiny feature.
When it didn't work, one by one I kept deleting all the new features I added, but no mater what I removed it refused to work, even after I deleted at least a week of full-time labor on newly written & tested code.
Nothing worked, and the NY World Maker Faire deadline was only a couple of weeks away. I spent two weeks searching and deleting a third week's worth of code.

Basically, I was declaring variable storage in 8-element wide arrays, such as "array(0,1,2,3,4,5,6,7,8)". That actually leaves space for 9 variables, and I was only going to index it from "array(1) to array(8)".
No problem, the index position of 0 was not going to be used, and that's how I wrote it all.
Since there was dozens of these arrays and limited memory, I declared them as "array(0,1,2,3,4,5,6,7)" to use only 8 variable spaces.

So there I was staring at this code for several weeks and not seeing what was really right there. Well it was in different parts of the file, but it looked essentially like this:

declare int array(7);
array(1)=1;
array(2)=2;
...etc...
array(7)=7;
array(8)=8;
 
I started computing with a US Navy Basic Electronics book back in the 70's (great book It had cartoon characters with the diagrams.
Yeah, they were great books. I think I still have some e copies somewhere on my laptop. Many of the other electronics books of the time were so arcane.

“free” copy of Turbo Basic “ on a DIY. 286 PC.
Similar here, except another free Basic on a home made Acorn Atom.

Only taught subject as a mature student, was Art, that is until some yobs burnt the college down
:hilarious:

Regret I never found time for a foreign language.
Yeah, me too.:(

spec
 
Last edited:
WOW!!!!

I have just done the same ruddy thing.... This time with longs..... Another two hours I'll never get back... I need these hours, times a flying for me these days...

I must learn to learn from myself...... unsigned int's cannot be shifted 16 times.... err... well they can, they just don't return the right numbers..
 
Perhaps a log of all our 'moments' I spent some time 'working' on the wrong file, could not understand why my 'improvements' were not working ? I had opened a recent file, in a tab alongside the actual build file, and happily typed in my C stuff , congratulated myself as it built several times with no errors ! easily fixed but daft :rolleyes: I always get confused with && and & etc, so I have a little yellow sticky on the wall.
 
I had opened a recent file, in a tab alongside the actual build file, and happily typed in my C stuff , congratulated myself as it built several times with no errors !
Yep... Been there, done that!! Spent hours wondering why the program STILL doesn't do what you've changed... Ahh!! Great fun..
 
Spot the bug:)

FOFFFFFF
FOFFFFFE
FOFFFFFD
FOFFFFFC
FOFFFFFB
FOFFFFFA
FOFFFFF9
FOFFFFF8
FOFFFFF7
FOFFFFF6
FOFFFFF5
FOFFFFF4
FOFFFFF3
FOFFFFF2
FOFFFFF1
FOFFFFEF
FOFFFFEE
FOFFFFED
FOFFFFEC
FOFFFFEB
FOFFFFEA
FOFFFFE9
FOFFFFE8
FOFFFFE7
FOFFFFE6
FOFFFFE5
FOFFFFE4
FOFFFFE3
FOFFFFE2
FOFFFFE1
FOFFFFDF
FOFFFFDE
FOFFFFDD
FOFFFFDC
FOFFFFDB
FOFFFFDA
FOFFFFD9
FOFFFFD8
FOFFFFD7
FOFFFFD6
FOFFFFD5
FOFFFFD4
FOFFFFD3
FOFFFFD2
FOFFFFD1
FOFFFFCF

spec


 
Last edited:
hi spec,
I see a couple of bugs
'O' versus 0
also
FOFFFFF1
FOFFFFEF

F0FFFFF0 is missing in the sequence.

E
 
hi spec,
I see a couple of bugs
'O' versus 0
also
FOFFFFF1
FOFFFFEF

F0FFFFF0 is missing in the sequence.

E

:) I might have known you would get it right away, Eric.

I once had something like, AGCDRERTYTOJUIGFRVCX, which was a key for enabling a certain function. After a day of no-go I phoned the vendor. They checked the code and stated that there was nothing wrong-it worked perfectly. Another day went by with no success. In frustration I phoned the company again and got the same guy with the same reply. But, just before ringing off he said, 'By the way, you do know that the eleventh character is zero.:banghead:

F0FFFFEF is not missing: who said the hex numbers are an ordered set.:D

spec
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top