When running code under the simulator in AVR32 studio, is there a way to print on the console window?
Printf would be ideal, but when I call it from my code, it executes, but does nothing.
When running code under the simulator in AVR32 studio, is there a way to print on the console window?
Printf would be ideal, but when I call it from my code, it executes, but does nothing.
There's no way to do that in the simulator yet. The simulator is mostly limited to testing algorithms and trying out the instruction set. More features will probably be added later, a basic I/O is pretty high on that list, but I'm not in a position to give any guarantees...
-Tore
Is there a way to print to the console from a program running under the JTAGICEMKII ?
At the moment you need a separate terminal connected to a USART to get output from your application.
There will soon be updated versions of the debugger and libraries which lets you do a number of system calls through JTAG. Expect an announcement in a month or two.
-Tore
Great, thanks !!
In the release notes for AVR32 Studio 2.1.0 it says:
* Serial communication support has been added to the terminal view.
It's a terminal like Hyperterminal or Putty. Simply open the "Terminal" view and create a new connection. You can choose from SSH, Telnet and serial connection types. Most of the advanced options of those mentioned above are missing but I think you'll still find it usable.
The software framework examples you mentioned should also work.
But you can't use printf to print to Hyperterminal or Putty. You must use one of the functions defined in ...\DRIVERS\USART\usart.c OR .../UTILS/print_funcs.h correct?
//**** usart.c ************************// void usart_write_line(volatile avr32_usart_t *usart, const char *string) int usart_putchar(volatile avr32_usart_t *usart, int c) int usart_write_char(volatile avr32_usart_t *usart, int c) //***** print_funcs.h ***********************// print_dbg(const char *str) print_dbg_char(int c) print_dbg_ulong(unsigned long n) print_dbg_char_hex(unsigned char n) print_dbg_short_hex(unsigned short n) print_dbg_hex(unsigned long n) print(volatile avr32_usart_t *usart, const char *str) { // Invoke the USART driver to transmit the input string with the given USART. usart_write_line(usart, str); } void print_char(volatile avr32_usart_t *usart, int c) { // Invoke the USART driver to transmit the input character with the given USART. usart_putchar(usart, c); } print_ulong(volatile avr32_usart_t *usart, unsigned long n) print_short_hex(volatile avr32_usart_t *usart, unsigned short n) print_hex(volatile avr32_usart_t *usart, unsigned long n
Is there no way to route printf to the USART instead of to the console?
Has anyone done this?
Is there no way to route printf to the USART instead of to the console?
You can define your own "_write" function and divert the characters to your own serial routines, here is an overview of what would be required to write anything going to stdout or stderr to a routine called "serial_write". The code is in "Bob C" which uses an include file to maintain as much Pascal compatibility as possible, but you can probably figure out what is going on. "need_mapping" is set when the serial port is opened, I found that I needed to change the stdout flags to get what I want. It also changes full lines (those ending with a line feed) so that both a carriage return and line feed are sent to the terminal. There is probably a more elegant way to do this, but it did the job for me. Note that printf is a memory hog, you need 4K of stack and around 10K of program space to run that pig.
integer _write (integer file, pchar ptr, integer length) begin FILE *pstdout ; pchar p ; char crlf[3] = "\r\n" ; if ((file == 1) lor (file == 2)) then begin if (need_mapping) then begin need_mapping = FALSE ; pstdout = stdout ; pstdout->_flags = (pstdout->_flags and not __SLBF) or __SNBF ; end p = (pvoid)((integer)ptr + length - 1) ; if ((*p) == 0xA) then begin /* full line */ if (length > 1) then serial_write (CONSOLE_UART, ptr, length - 1) ; serial_write (CONSOLE_UART, addr(crlf), 2) ; end else /* prompt */ serial_write (CONSOLE_UART, ptr, length) ; return length ; end else return 0 ; end