AVR Studio debugging USART, UDR

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

ATtiny2313V
How do I simulate incomming data via "RS232" in the dbugging mode? I whant to put a value in UDR register and simulate RX complete interrupt. Same as I can do on I/O pins PINx just click the pin number and step forward.
Regards

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

You can do it in AVR Simulator 2. See the Simulator2 Stimuli chapter in AVR Studio Help for details.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

I have looked through the help files in my AVR Studio installation and can only find a very simpel description "Port logging and stimuli" just as information. Where can I find a propper manual?
Regards

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

What else do you need to be explained - how to press keys on your keyboard or how to use a mouse? :D

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

In the simulator manual the last page is "Simulator2 Stimuli in AVR Studio" and it ends with:

Quote:
Example stimuli file
The following example shows how ADC conversion results can be injected into the ADC data registers, and an ADC interrupt be triggered by setting the ADIF flag in ADCSRA. This example is set up for an ATmega164 but should work on most AVR devices with an ADC. The example does not show meaningful use of ADC but illustrates how stimuli files can be used.

The example also shows use of logging and break directives.

// Initial delay

#100

// Set up logging ADC and ADCSRA to file adc.log

$log ADCL

$log ADCH

$log ADCSRA

$startlog adc.log

// start of repeat loop

$repeat 100

// Assuming TCNT1 is running, use as data for ADC

ADCL = *TCNT1L

ADCH = *TCNT1H

// Set ADIF flag in ADCSRA, this will trigger ADCC interrupt

ADCSRA |= 0x10

#30

$endrep

// Stop logging (close log file)

$stoplog

// break program execution

$break


Is that the page you have read? What more do you need to know? That example is feeding values to the ADC not the UDR but surely you can see that the technique is going to be similar?

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

my mouse handling is excelent! but keyboard.... hmmm
So if I run in Simulator 2 mode the dialogbox for Stimuli and logging doesn't show???? So I can now run .sti files in debugging mode and the input pins change acording to my .sti file. I'm running at 8Mhz Cpu clock devided by 1. My problem is now to determinate length of start bit and the rest of the databits and stopp bit,I assume?? . Asynchronous, 2 stop bit, no paraty, 19200 baud.
Regards
000000001:01
000000720:00
000000960:01
000001200:00
000001440:01
000001680:00
000001920:01
000002160:00
000002400:01
000002640:00
000002880:01
000003840:00
999999994:0
999999995:12
999999996:00
999999997:00
999999998:10
999999999:FF

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

That won't work in sim-1, use sim-2 and if you Studio doesn't offer the option it's likely out of date.

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

OK!
You are right! I looked at the earlier coment about ADC. But how about this in simulator 2? In the ADC example the ADIF flag is set in the same way so way not RXC?

// Initial PORTB
PINB = 0xFF //This works
#30
// Program in main loop doing nothing
// Set RXD pin 2 to 1 for test
PIND |= 0x01 //This works
#5
UDR |= 0xFF //No reaction? UDR=I/O register?
#30
// start of repeat loop
$repeat 10
// Assuming RXEN=1, RXCIE=1 and I=1 in SREG
UDR = 0x13 //No reaction?
// Set RXC flag in UCSRA, this will trigger recive interrupt?
UCSRA |= 0x80 //No reaction?
#50
$endrep
// break program execution
$break

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

Be warned that the stimli thing in Studio for sim 2 is one of the very latest "features" that's been added to the program. I'm not sure I'd have total confidence that it is going to trigger RXC. If it doesn't one could raise this as a fault with Atmel but be warned that 4.18SP3 is apparently the last ever release of "Studio 4" and in future (the long time promised) "Studio 5" may be quite quite different. There's a strong suggestion it'll be based on the Eclipse IDE just as Studio32 is. What it offers in terms of simulation is one of the great unknowns but it would seem a shame that if Atmel put so much recent into Sim V2 and got so close to "getting it right" that it might be abandoned so I imagine it's going to resurface in the new Studio in some form.

As for release dates - it's the usual "moving goalposts" game from Atmel.

In the interim have you ever considered simply building the code into a real AVR and debugging with some kind of On Chip Debug interface such as JTAG, PDI or debugWire ?

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

OK!
Thanks for your intrest and help in this matter :)
If I setup a schedule with time delays and shift the RXD pin on port D as 11 bit frame the simulator 2 will generate a RXC interupt. There will not be any data in UDR but it dosen't matter.
Regards!

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

There is only simulator selection,I'm using Atmel Studio 7.0

And I can't change RXDATAL in stimuli files.

Which IDE do you use?

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

Xiao wrote:

There is only simulator selection,I'm using Atmel Studio 7.0

And I can't change RXDATAL in stimuli files.

Which IDE do you use?

The simulator works fine for simulating the cpu, but for peripheral devices, it's best to just dummy a response with both good data and bad data to test the rest of your code.

So a call to a function that reads a line of data, or perhaps a command string, just hard code a return string in your USART function and go on with your debugging session...

Remove the dummy function once you have real hardware and can run a debugger with real inputs/outputs...

 

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

Lets go Brandon!

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

Why are you even worried about using a simulator?  Hook up your UART and give it a try in the real world...COME BACK TO REALITY, it's 2021 now!!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

He's developing a bootloader so it's not so much observing the UARt data delivery that matters here but seeing "what comes next" when that data is used to SPM. So I think he just wants to use "Stimuli" to feed the protocol delivery. 

 

(of course that may not even work as usually a PC-Bootloader protocol tends to be a two-way dialog with what happens next depending on what just happened so just feeding a stream of "stimul"ated data to it with no interaction may not work).

 

As I said in the other thread - for a 4809 just get a curiosity, use the real silicon and feed it from the real PC based protocol program and "watch" what's going on (both delivery and SPM) using the debugger on Curiosity.

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

I'll say it again  COME BACK TO REALITY, it's 2021 now!! crying (look at original post)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:
(look at original post)

do you mean the opening post - #1, from 2011 - or the recent resurrection ?

 

The resurrection seems related to this: https://www.avrfreaks.net/forum/miscellaneous-questions-customizing-bootloader-mega4809

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

Good Luck.