Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:38 21 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Picomite: Possible issue in error() for CSubs

Author Message
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1682
Posted: 06:06pm 05 Aug 2022
Copy link to clipboard 
Print this post

@matherp

Hi Peter,
I just played a bit with my BitOrderReverse code and I think there is an issue with the error() for CSubs.

When I use it with a CMM2 (compiled for CMM2) it works fine, but the CSub for my Picomite crashes when it hits the error() function (compiled with option -o0).
//Bitorderreverse CSub
#include "PicoCFunctions.h"

void bor(long long *orig, long long *nbits, long long *reversed)
{
int i = 0;
unsigned int nb = *nbits;
unsigned long long r = 0;
unsigned long long ONEBIT = 1;

if (nb){
nb-=1;

for(;i<=nb;i++)
{
if (*orig & (ONEBIT<<i))
r += ONEBIT<<(nb-i);
}
}
else {
//not working! --> crash on PicoMite!
 error("0 is invalid (valid is 1 to 64)\r\n");
 return;
}
*reversed=r;
}

Sample code for CMM2 (works) and Picomite (crashes):
Bitorderreverse.zip

BTW: A fast (7us/378MHz) bitorderreverse CSub for 8 bits on Picomite, for those who want it:
Bor_8.zip

I think there ist also an issue with MMPrintString(). But I haven't checked that thoroughly.

This is not an urgent issue! (It seems I'm the only one using CSubs. )

I hope you are well!
Best regards
Michael
causality ≠ correlation ≠ coincidence
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10628
Posted: 07:53am 06 Aug 2022
Copy link to clipboard 
Print this post

Almost certainly the handling of constant strings by the compiler. You can try various compiler options or search the CMM2 CSUB thread for using the original way of defining constant strings (a la MM2)
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1682
Posted: 10:40am 06 Aug 2022
Copy link to clipboard 
Print this post

  matherp said  Almost certainly the handling of constant strings by the compiler. You can try various compiler options ..

This is what I use:
arm-none-eabi-gcc -c -mcpu=cortex-m0 -mfloat-abi=soft -mthumb -Wall -Wno-main -ffunction-sections -O0 -fPIC -I. main.c -o main.o

  matherp said   ... or search the CMM2 CSUB thread for using the original way of defining constant strings (a la MM2)

Hmm, I think I've already tried all the options (even "GetTempMemory").
There aren't that many.

At least that should work:
#include "PicoCFunctions.h"
void perro(char *s)
{
error(s);
}

perro("Hello")
end
'File perror.bas written 06-08-2022 12:25:46 v1.44
CSUB perro
00000000
B082B580 6078AF00 681B4B04 687B001A 47900018 46BD46C0 BD80B002 10000364
End CSUB


Do you have a working example for error()?

Best regards
Michael
causality ≠ correlation ≠ coincidence
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1055
Posted: 12:52pm 06 Aug 2022
Copy link to clipboard 
Print this post

I get the same result on latest firmware,i.e. reboots if bits =0 and MMPrintString() doesn't print, PutConsole too I think, but works on 5.0704
I had some other tests which work on this version but not the latest.
I need to step through the firmware versions and see where it became broken.

What version are you using.
--------------------------------------------------
Connected to: PicoMite 5.0704
--------------------------------------------------

BitOrderReverse Demo

Input:
No of Bits :     0
[15] Bor(a,nBits,b)
Error : 0 is invalid (valid is 1 to 64)

Regards
Gerry
F4 H7FotSF4xGT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10628
Posted: 12:58pm 06 Aug 2022
Copy link to clipboard 
Print this post

It seems the later compiler has changed the location of the call table. Try updating the header file to set the base address at 310

#define BaseAddress   0x10000310


Thanks to Gerry for pointing out it worked in 5.07.04. As always fuller information yields an easy fix
Edited 2022-08-06 23:01 by matherp
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1682
Posted: 01:00pm 06 Aug 2022
Copy link to clipboard 
Print this post

  disco4now said  What version are you using.

5.07.05b15

Hi Gerry,
thanks for assisting!
Very good idea to use a different firmware!

Best regards
Michael
causality ≠ correlation ≠ coincidence
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1682
Posted: 01:08pm 06 Aug 2022
Copy link to clipboard 
Print this post

  matherp said  It seems the later compiler has changed the location of the call table. Try updating the header file to set the base address at 310

#define BaseAddress   0x10000310


Hi Peter,
I can confirm my example
#include "PicoCFunctions.h"
void perro(char *s)
{
error(s);
}

now works!

Seems to be solved! Thanks Peter, thanks Gerry!

EDIT
Working BitOrderReverse for version 5.070515:
Bor(a,nBits,b)
'File bor.bas written 06-08-2022 15:15:40 v1.44
CSUB bor
00000000
4657B5F0 464E46DE B5E04645 B085680F 2F009203 1E7BD04E 6803469A 46982100
68432220 469C2000 23004691 90002601 E0229101 40910031 0032468B 409A4641
400A4660 40014659 D013430A 21204652 42491AD2 18524693 0031D419 000D4091
00324659 0014408A 9A019900 416A1909 92019100 429F3301 2220D010 189A4252
464AD5D8 1AD20031 468B40D1 4659E7D5 1A52464A 40D10031 E7E1000D 98009B03
60189901 B0056059 46BBBCF0 46A946B2 BDF046A0 48034B02 4478681B E7F24798
10000368 0000000A 73692030 766E6920 64696C61 61762820 2064696C 31207369
206F7420 0D293436 4700000A
End CSUB


I'm afraid this means that in the future we might need different CSubs for different FW versions.
Edited 2022-08-06 23:22 by twofingers
causality ≠ correlation ≠ coincidence
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1055
Posted: 01:20pm 06 Aug 2022
Copy link to clipboard 
Print this post

So looks like from PicoMite V5.07.05b13 onwards the new entry for the baseaddress is required.
F4 H7FotSF4xGT
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1682
Posted: 01:24pm 06 Aug 2022
Copy link to clipboard 
Print this post

  disco4now said  So looks like from PicoMite V5.07.05b13 onwards the new entry for the baseaddress is required.

Thanks Gerry for the investigation!
causality ≠ correlation ≠ coincidence
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025