Hello,
I wrote a simple program to demonstrate what is happening. I know I'm doing something wrong, but Arduino´s memory management is a weird animal.
If I use a function in an infinite loop, my program crashes due to lack of memory.
this works ok:
but this one crashes repeatedely. this is caused by the call to the function. I can´t understand why this causes memory use.
In an arduino uno, the count goes until 247 and goes back to Appstart.
any help?
Thank you all
I wrote a simple program to demonstrate what is happening. I know I'm doing something wrong, but Arduino´s memory management is a weird animal.
If I use a function in an infinite loop, my program crashes due to lack of memory.
this works ok:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Dim n As Int = 0
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Do While True
n=n+1
Log(n)
Loop
End Sub
Sub teste(nn) As Int
Return nn
End Sub
but this one crashes repeatedely. this is caused by the call to the function. I can´t understand why this causes memory use.
In an arduino uno, the count goes until 247 and goes back to Appstart.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Dim n As Int = 0
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Do While True
n=n+1
Log(test(n))
Loop
End Sub
Sub test(nn) As Int
Return nn
End Sub
any help?
Thank you all