(Solved, sort of) Live watch ports etc.

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using the AS7 simulator/debugger, is it possible to show a PORT output in the Live Watch window?

If so I have not found it...

What I would like to be able to do is setup so I can visualize the port over a considerable amount of time without stepping from breakpoint to breakpoint.

I can see variables in the live watch, but cannot (seem to) observe the port itself.

Using a variable that is set when I set the port works to a point, but something else is clobbering the port at some point, and is not reflected in the variable.

 

The code is from a client, and is a disaster (to be polite. Too many files, full of spaghetti code!). I have a feeling it is a runaway pointer.

 

I do not use the simulator much, so am not familiar with all of its capabilities. Can a breakpoint be set on a change in port value?

 

This topic has a solution.

David (aka frog_jr)

Last Edited: Thu. Nov 3, 2016 - 02:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Studio 7 (and 6,5,4,3) only updates the IO view when the execution stops. That's because the bandwidth of the debug interface (esp debugWire) may not be enough for a real time dump of all the AVR internals. Having said this, up to AS4 there was "auto-step". I always thought it was a bit of a mickey-mouse gimmick but it did effectively keep stepping/displaying automatically so it might offer something along the lines of what you want. I think it might have been something like 100 updates/second.

 

(personally I would just try to log the activity somewhere and extract it afterwards or maybe spew it out of a fast running UART port - perhaps set up a fast ticker interrupt to "sniff" the PORT state regularly?)

Last Edited: Wed. Nov 2, 2016 - 04:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
perhaps set up a fast ticker interrupt to "sniff" the PORT state regularly?
Ah! That gives me an idea of how to track it down (maybe). Fast timer reading port and setting a flag (halting) on first occurrence of that not agreeing with the variable I am setting when I write the port. Hopefully, it will let me narrow down what section of code is responsible.

 

Now, back to the garbage pit!

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

<RANT MODE>

This has to be the most inconsistantly arranged program ever devised. If I hadn't signed an NDA, I think I would submit it for the International Obfuscated C Code Contest!

It is anti-modular, file names have NOTHING to do with the contents, and simple peripheral functions are strewn across multiple files. Who wrote this??? Where are any comments or documentation???

ASM functions for non-time critical sections, intricate multiple C functions called within ISRs, non-volatile variables in functions and ISRs, and I can't count the number of global variables.

My 5 year old grandson exhibits more logic than this.

Apparently, the "programmer" is no longer with company, so I cannot ask any questions about what various sections of the "code" are supposed to accomplish.

This code seems to violate EVERY semblance of good coding practices.

Arrrgh!

</RANT MODE>

I just had to get it out!

Now to untangle some more spaghetti.

 

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

frog_jr wrote:
This has to be the most inconsistantly arranged program ever devised.

The code you are working on or Studio?

 

Sometimes it's hard to tell

 

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
The code you are working on or Studio?
LOL, I needed that! (It's the code... today!)

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Live watch can only observe RAM locations as far as I can remember, so PORTS are not available for it... The simulator mimics this behaviour (although I guess that's just by implementation, nothing to do with the actual simulator framework...)

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can see the PORTS output in the simulator.  The PIN can be tricky though.

 

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Solved (sort of)

I finally found the problem with the mysterious PORT! Not so much a runaway pointer as just plain stupid code.

 

Compile the code, aha no warnings, no errors; but wait!

  • What is that "-w" lurking in C compiler miscellaneous project settings?
  • Why is there no reference to DDRx? (Much less any PORT?)
  • What are these obscure values of 0x0021, 0x0024, 0x0027, etc. that are used as target addresses?
  • Did I mention there are no comments?
  • Why is (just about) every variable int (weren't any other types able to come out and play that day?)
  • And the non-atomic ints accessed in the main, but set in ISRs
  • Did I mention there are no comments?

 

Once I removed the "-w", there were only 927 warnings!

 

Bottom Line:

The code was reading an int from an FPGA which normally returns values from 0x00 to 0x0F. Once in a great long while the FPGA would OR an 0x8000 to that value. (I haven't jumped into the FPGA to figure out why as yet, or even why it isn't just providing a single byte.)

Through a series of complicated procedures (all of which are totally useless) the value is used to set bits (using an OR operation) in the DDR register of a port (using the 0x0024 as an int pointer). However, when that 0x8000 hits, the code would also OR 0x80 with the value in the associated PORT register.

 

Well, not bad for just about 24 hours with the code.

Now to go back to the client and give them the bad news. This code has more bugs than the Museum d’Histoire Naturelle, Smithsonian, Natural History Museum(UK) and the Zoologische Staatssammlung combined!

 

Where should I start? ...

Oh yeah!

Project/New

 

 

 

 

David (aka frog_jr)