Weirdest bug I've ever seen

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

I'm trying to generate UBRR in preprocessor...

The preprocessor interpreter generates the correct result.

However, placing those values into UBRRL and UBRRH output completely different results... (in the debugger)

Check out the pastebin, it's much clearer there.

http://pastebin.com/m3d325752

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

How are you debugging your code? I hope you realise that with that baud rate and clock the error is pretty big for reliable comms even with x2.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Yeah it is, unfortunately I'm using internal RC too at this time...

It's just temporary and works pretty good...

2.1% error

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

P.S. debugging with WinAVR/AVRStudio debugger

Basically using the IO Viewer window and watching UBRRL and UBRRH

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

Quote:
Basically using the IO Viewer window and watching UBRRL and UBRRH
haha then it may just be a simulator bug.
https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50435&highlight=stuffed
I thing there is a new HTML file for a fix with the latest service pack or as a separate file, may fix things up.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Your link suggests you are building for the mega8? You may want to sit down and have a little think about the IO address of UBRRH and UCSRC and what the URSEL bit is doing for you.

Page 149 of the mega8 datasheet is also going to be very revealing I think.

No doubt then you will understand why the simulator cannot show you the contents of UBRRH.

(but as most baud rates are only a value in UBRRL and you are generally writing 0 to UBRRH (or nothing because 0 is the default) you don't actually need to see UBRRH anyway - anyway YOU know what you wrote to it!)

Cliff

(this is not a "bug" in the simulator)

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

Quote:
this is not a "bug" in the simulator
but definetely a bug in my head!! I thought I was answering a thread about the M128 :? I must have had several topics opened and answered the wrong one :?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly