Forum > Embedded - AVR

Noting responds when sending integers trough my UART

<< < (2/3) > >>

ccrause:

--- Quote from: pascalbythree on December 01, 2023, 10:27:23 am ---My AVR is compiled for 115200 BAUD
My Terminal APP is set at 9600 BAUD

And UART.WriteStrLn('WvW!'); does work fine.
And UART.WriteStrln(IntToStr(i)); shows no values, and program loop does not run.

Using:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ----dF_CPU:=12000000
--- End quote ---
The ratio between your firmware baud and terminal app baud is 12.  It should be the same if everything is configured correctly.  Did you change the attiny841 fuse settings?  If not, it will default to the internal 8MHz oscillator with the CKDIV8 bit set, so it is probably running at 1 MHz.

Hartmut:
Be very carefull if you use the 'str' command: on my ATmega16 this consumes 3612 (!) Bytes of code plus 310 (!) Bytes of RAM! (FPC 3.2.2)

You can and should observe the amount of code & data for your program in the Lazarus-IDE (see screenshot). Possibly FPC shows the same. Your first 'str' command consumes the above additional amount of space. Check it.

If you are scarce with Memory, build your own 'str' conversion procedure. If you need help for that, let me know.

And very important: the suggestion from Thaddy will consume 256 Bytes (!) in RAM:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var tmp: string;For an signed 16-bit Integer better use:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var tmp: string[6];

pascalbythree:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---avrdude -c %avrdudeidch2% %usbportch2% %programoverridech2% -p %avrdudemcunamech2% -U flash:w:%output_hex_filech2% -C %avrdudeconffilech2% -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h -v

Are this the right fuses for AVRdude ?

ccrause:

--- Quote from: pascalbythree on December 02, 2023, 10:26:29 am ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---avrdude -c %avrdudeidch2% %usbportch2% %programoverridech2% -p %avrdudemcunamech2% -U flash:w:%output_hex_filech2% -C %avrdudeconffilech2% -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h -v
Are this the right fuses for AVRdude ?

--- End quote ---

You didn't show any fuse information. A simple way to check the fuses is to run a basic avrdude command:

--- Code: ---avrdude -c usbasp -p m328p

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)

avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.
--- End code ---

To check what the fuse settings mean, open https://www.engbedded.com/conffuse/ and select your controller from the dropdown list.  It will start by showing the default values.  You can then change the fuses and it will show the fuse values towards the bottom of the page.

Thaddy:

--- Quote from: Hartmut on December 01, 2023, 03:11:11 pm ---Be very carefull if you use the 'str' command: on my ATmega16 this consumes 3612 (!) Bytes of code plus 310 (!) Bytes of RAM! (FPC 3.2.2)

--- End quote ---
Str is the most lightweight that is standard supplied and just fits. IntToStr is much, much heavier as is writestr, which is an alternative from system as well.
But indeed for pure byte sized characters there are shortcuts if you write them yourself or pick it up from some dedicated library.

You were right about the shortstring, though. I overlooked that.
That said, with proper optimizarion str should not exceed 1200 to 1600 bytes. Still a lot if it can be done in about 400 bytes.and much less in bit of assembler.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version