Forum > Embedded - AVR

Noting responds when sending integers trough my UART

(1/3) > >>

pascalbythree:
It all got to work so far..


--- 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";}};} ---begin  EEPROM_write($1,115200);  i:=0;    baudrate := EEPROM_read($1);  UART.Init(115200);    ModePortA(3,True); // WVW LED  repeat     inc(i);         if  i = 10 then UART.WriteStrLn(IntToStr(100));         if i>10 then i:=1;                          WritePortA(3, True); // WVW LED         delay_ms(15);         WritePortA(3, False); // WVW LED         delay_ms(15);  until false;end. 

A new problem, can somebody help me before i have to cancel my controller ?

Incase UART.WriteStrLn is used to send  a string, everything works fine.

Incase UART.WriteStrLn is used to send  a integer, it seems to stop, nothing appears in my UART terminal.

Anybody got a idea what i am doing wrong? What setting it migh be and where?

Dit not have this problems with the ATmega328, and now idea what corner i should search.

Greets, WvW

Incase you are all not able to awnser i am going to remove this topic then. Never know what to oversee


EDIT: using this to compile:


--- 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";}};} ---ppcrossavr -Tembedded -Wp%fpc_mcuname% -MObjFPC -vw-n-h- -Cpavr5 -Sg -Pavr -g -a -al -XPavr- -Sm -dF_CPU:=%frequency% %pasfilename% -O3

This all using the ATtiny841 !

ccrause:

--- Quote from: pascalbythree on November 30, 2023, 03:36:40 pm ---Anybody got a idea what i am doing wrong? What setting it migh be and where?

--- End quote ---
Where is the code for IntToStr? Did you use the SysUtils unit (which normally isn't compiled for avr-embedded) or write your own version of IntToStr?


--- Quote ---Dit not have this problems with the ATmega328, and now idea what corner i should search.

--- 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";}};} ---ppcrossavr -Tembedded -Wp%fpc_mcuname% -MObjFPC -vw-n-h- -Cpavr5 -Sg -Pavr -g -a -al -XPavr- -Sm -dF_CPU:=%frequency% %pasfilename% -O3
This all using the ATtiny841 !

--- End quote ---
Do not specify -Cpavr5, the subarch for attiny841 is avr25 not avr5.  It is not necessary to specify the subarch with the -Cp switch, the compiler knows which subarch to use. It is enough to just specify the controller name using the -Wp switch.

Thaddy:
Instead of inttostr, you can use the str procedure which should be available for embedded systems. Str is in the system unit and does not rely on sysutils. Note it needs an intermediate variable since str is a procedure and not a function.

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";}};} ---begin  i:=0;    UART.Init(115200);    ModePortA(3,True); // WVW LED  repeat     inc(i);     if i>10 then i:=1;           UART.WriteStrLn('WvW!');                 UART.WriteStrln(IntToStr(i));            WritePortA(3, True); // WVW LED         delay_ms(5);         WritePortA(3, False); // WVW LED         delay_ms(5);  until false;end.
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";}};} ----Tembedded -Wpattiny841 -MObjFPC -Cpavr25 -Pavr -g -a -al -XPavr- -Sm =-dF_CPU:=12000000 WVW_CHANNEL_2.pas -O3
Anybody got another idea what i am doing wrong ? / a way to get the baud settings equal ? Grtz WvW

Thaddy:

--- 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";}};} ---{$H-}var tmp:string;begin  EEPROM_write($1,115200);  i:=0;    baudrate := EEPROM_read($1);  UART.Init(115200);   ModePortA(3,True); // WVW LED  repeat     inc(i);         if  i = 10 then         begin           str(100,tmp);            UART.WriteStrLn(tmp);         end;         if i>10 then i:=1;                          WritePortA(3, True); // WVW LED         delay_ms(15);         WritePortA(3, False); // WVW LED         delay_ms(15);  until false;end.As ccrause already explained you can not standard use inttostr, because the sysutils unit is too large for many embedded systems. The above code only relies on system and should work even on micro avr etc.
Str() is part of the Pascal language and directly implemented by the compiler as is evident from the system.fpd file.

Navigation

[0] Message Index

[#] Next page

Go to full version