Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:40 26 Oct 2021 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 V5.07.01b16: Breaking changes and CSUBs

     Page 1 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 12:37pm 12 Sep 2021
Copy link to clipboard 
Print this post

PicoMiteV5.07.01b16.zip

Breaking change to PINCTRL function
GP prefix is now mandatory for start pin parameters. Normal pin numbers can not be used in this function

Breaking changes to SETPIN, to improve compatibility with other MMBasic variants

SETPIN n, m, COM1 ' allocates UART0 pins to COM1. If the pins don't form a UART0 RX/TX pair then errors, pin order is not important
SETPIN n, m, COM2 ' allocates UART1 pins to COM2. If the pins don't form a UART1 RX/TX pair then errors, pin order is not important
SETPIN n, m, p, SPI 'allocates SPI0 pins to SPI. If the pins don't form a SPI0 RX/TX/CLK triple then errors, pin order is not important
SETPIN n, m, p, SPI2 'allocates SPI1 pins to SPI2. If the pins don't form a SPI1 RX/TX/CLK triple then errors, pin order is not important
SETPIN n, m, I2C ' allocates I2C0 pins to I2C. If the pins don't form a I2C0 SDA/SCL pair then errors, pin order is not important
SETPIN n, m, I2C2 ' allocates I2C1 pins to I2C2. If the pins don't form a I2C1 SDA/SCL pair then errors, pin order is not important

Commands are then

OPEN "COM1:baud"
OPEN "COM2:baud"
SPI command and function
SPI2 command and function
I2C command
I2C2 command

PWM will remain unchanged. i.e. SETPIN n, PWMna  where n=0-7 and a=AorB. This reflects the fact on the PicoMite that you can use a PWM B channel without an A unlike any other MM e.g PWM 0,1000,,50

CSUbs

See here for more info

Commands to compile and link for the PicoMite assuming the source file is main.c are

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
arm-none-eabi-ld -nostartfiles -T arm-gcc-link.ld -o main.elf main.o


MMBasic for DOS program to convert the .elf file to the Basic statements:

armcfgenV143.zip

Header file for linking in internal routines (untested):

PicoCFunctions.zip



Example source file:
void strrev(unsigned char in[], unsigned char out[]) {

  unsigned int i;

  unsigned int len;

  //MMBasic stores the length of the string in the
  //first,0th,byte
  len=in[0];

  //Set the length of the output string
  out[0]=len;

  //Do the reverse copy
  for(i=1;i<(len+1);i++){
      out[i]=in[len-i+1];
  }

  //and return the length of the string
}
void main(void){}


Compiled output and demo
Dim a$="1234567890"
Dim b$
strrev a$,b$
Print b$

CSub strrev
00000000
B085B480 6078AF00 687B6039 60BB781B B2DA68BB 701A683B 60FB2301 68BAE00D
1AD368FB 687A3301 6839441A 440B68FB 701A7812 330168FB 68BB60FB 68FA3301
D3EC429A BF00BF00 46BD3714 4770BC80
End CSub


Bug fixes
Fixed bug in LONGSTRING RESIZE

Outstanding issues
I haven't looked at led-bloons PIO issue yet

Coming next (hopefully)
The ability to define a CSUB which will run stand-alone on the second processor
Edited 2021-09-12 22:39 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 968
Posted: 01:22pm 12 Sep 2021
Copy link to clipboard 
Print this post

Updated TINAM in line with above changes to PINCTRL and SETPIN just for completeness. :)

PicoMite TINAM doc 0912.zip
Edited 2021-09-12 23:23 by Mixtel90
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 1863
Posted: 03:01pm 12 Sep 2021
Copy link to clipboard 
Print this post

Very nice ... I look forward to escaping from my Linux port and drifting back onto the Pico for a while.

Best wishes,

Tom
CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 968
Posted: 04:51pm 12 Sep 2021
Copy link to clipboard 
Print this post

LIST FUNCTIONS shows MM.Info( but also MM.Info$( 3 times.
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 05:26pm 12 Sep 2021
Copy link to clipboard 
Print this post

Oops


PicoMiteV5.07.01b16.zip
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 968
Posted: 05:51pm 12 Sep 2021
Copy link to clipboard 
Print this post

>Phew!<

Having said that... strange error caused by fat fingers:
> setpin 2,1,c0m1
Error : 0 is invalid (valid is 8 to 12)

With thinner fingers it seems to work.

reversing 1 & 2 gives the expected error.

> setpin 1,2,c0m1
Error : Invalid configuration

.
Edited 2021-09-13 04:23 by Mixtel90
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 897
Posted: 07:06am 13 Sep 2021
Copy link to clipboard 
Print this post

@Peter

The current ADC command is very nice in respect that it can run in the background. You get an interrupt when the array is filled with data. This is perfect for taking a single shot sample run. If you however want to take continuous samples the best I can do with the current command is alternating (ping-pong) buffers (pseudo code)


set an intterupt
start the adc filling array a()
buffer = 1

in the interrupt
if buffer=1
restart the adc filling array b(): buffer = 2
else
restart the adc filling array a(): buffer = 1

in the main process either a() or b() while the other is filled.


Or do you see a better way ? The ADC does not support "round robin" on the array correct ? Can de ADC handle multidimensional arrays ? something like
ADC START array( ,n) where n is alternating between 0 an 1 in above example ?

About MATH, I can use MATH ADD and MATH SCALE to calculate the actual measured value of each sample (in single dimensional arrays), is there any function in the MATH range I can use to find the MIN and MAX value (other than a MMbasic FOR/NEXT loop) ?
My current code has loads of for-next loops to process all the data, and I want to speed things up by using the MATH commands.

Thanks in advance for your answer,

Volhout
Edited 2021-09-13 17:07 by Volhout
If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 07:24am 13 Sep 2021
Copy link to clipboard 
Print this post

  Quote   If you however want to take continuous samples the best I can do with the current command is alternating (ping-pong) buffers (pseudo code)


That is currently the best approach

  Quote   is there any function in the MATH range I can use to find the MIN and MAX value


? math(max a())
? math(min a())

Check the CMM2 manual. The MATH command and function on the PicoMite are identical
Edited 2021-09-13 17:27 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 897
Posted: 08:33am 13 Sep 2021
Copy link to clipboard 
Print this post

Hi Peter,

EDIT: I removed the original text, since it was my oops. I had OPTION BASE set to 0. Where as I used 1 as the first element in arrays.

However...

I found something other that I needs advise on.

Option base 1
n=1000
Dim a(n),b(n)

'fill array with sine wave
Print
Timer = 0
For i=1 To n
 a(i)=Sin(Pi*i/(n/5))
Next i
Print "fill array sine funct  ";Timer

'calculate min, max, mean from array
Print
Timer = 0
p = Math(Max a())
l = Math(min a())
m = Math(mean a())
Print "max,min,mean math()    ";Timer
Print "max = ";p;"  min = ";l;"   mean = ";m

'calculate min max mean classical way
'Print
Timer = 0
p=0:l=0:m=0
For i= 1 To n
 p = Max(a(i),p)
 l = Min(a(i),l)
 m = m+a(i)
 m = m / n
Next i
Print "max,min,mean classic    ";Timer
Print "max = ";p;"  min = ";l;"   mean = ";m


fill array sine funct   119.462

max,min,mean math()     6.267
max =  1  min = -1   mean =  0.1273213365
max,min,mean classic     244.606
max =  1  min = -1   mean =  1.573877524e-08


the classical way, the mean value of this 5 cycle sine wave is 1.5e-8 (rounding error). But using the Math(Mean) function the error is larger.
Edited 2021-09-13 19:20 by Volhout
If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 09:23am 13 Sep 2021
Copy link to clipboard 
Print this post

Can't replicate: I get the same answer in all three calcs (b16) - replying to first question - will look at second
Edited 2021-09-13 19:25 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 897
Posted: 09:36am 13 Sep 2021
Copy link to clipboard 
Print this post

Sorry....

The mean of 5 cycles is 0, the mean of 5 half-cycles is 1/5 of sqr(1/2) is 0.12...
I filled the array with 5 half cycles. 360 degrees is 2*pi, not pi.

I will hide into the corner with my tail between my legs and lick my wounds.
Deeply ashamed...

Volhout
Edited 2021-09-13 19:37 by Volhout
If nothing goes right ... turn left
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 548
Posted: 11:53am 13 Sep 2021
Copy link to clipboard 
Print this post

Hi Peter,
Here is an updated PicoCFunctions.h header file.

PicoCFunctions.zip
It contains changes I discovered when testing CSUBs which accessed the MMBasic functions via the header file on the ArmmiteF4 and I have made same corrections to this file.

See the ArmmiteF4 CSUBs link for more information.

V1.6  
Added parenthesis around (BaseAddress+0xx) expressions to force correct evaluation
Option Macro now -->  #define Option (*(struct option_s *)(unsigned int)Vector_Option)

Added two useful #defines
#define NOP()  __asm volatile ("nop")
#define USERLCDPANEL            16



The code and CSUB below where used to verify the header file. Its a crude display driver that just prints that the DrawRectangle and DrawBitMap routines have been called. They also set HRes,VRes and Display_TYPE to prove they work.

Issue with uSec()
I think there is an issue with the uSec() call. The CSUB hangs when it is called. I accidently discovered a workaround, it does not hang if a putConsole() call is made before the uSec() called e.g.
//workaround for uSec() issue. Hangs without putConsole()
void myuSec(unsigned int a){
putConsole(0);
uSec(a);
}
This may help to discover the cause.

Another thing I notice was setting a USER panel i.e.
OPTION LCDPANEL USER ,320,240
was that HRes and VRes are set and available to the driver. However if they are updated via the CSUB that OPTION LIST will always show the original values entered with the OPTION LCDPANEL USER command. If no OPTION USER LCDPANEL is used the HRes and VRes dont show in OPTION LIST, even though they are set in the CSUB, and readable as there correct values in the CSUB.




  Quote  
?
hex$(PEEK(CFUNADDR HEADERTEST))
? MM.INFO$(
pin 10),10
? MM.INFO$(
pin 11),11
? MM.INFO$(
pin 12),12
? MM.INFO$(
LCDPANEL)
'timer=0
'TEST a%,b%,c,d$,e$
HEADERTEST 10,11,12,1

? MM.INFO$(
pin 10),10
? MM.INFO$(
pin 11),11
? MM.INFO$(
pin 12),12

OPTION LIST

CLS 10
?
"DISPLAY_TYPE=",MM.INFO$(LCDPANEL)
CLS 16
?
"DISPLAY_TYPE=",MM.INFO$(LCDPANEL)
TEXT 132,180,"X"
?
"HRES=",mm.hres:? "VRES=",MM.VRES
TEXT 320,240,"X"
?
"HRES=",mm.hres:? "VRES=",MM.VRES

end
'File ST7789.bas written 13-09-2021 16:57:05 v1.43a
CSUB HEADERTEST
00000055
'HEADERTEST_v100
AF00B580 46C046C0 BD8046BD
'p_string
B084B580 6078AF00 60FB687B 681B4B04 68FB001A 47900018 46BD46C0 BD80B004
1000032C
'p_int
B094B5B0 6078AF02 490D6039 000C6809 000A6879 000B17C9 25086839 91001978
4B0847A0 001A681B 0018197B 4B064790 2020681B 46C04798 B01246BD 46C0BDB0
10000330 1000032C 10000310 B084B580 60F8AF00 607A60B9 4B0C603B 0018447B
FFBCF7FF
210A69BB F7FF0018 4B08FFC9 0018447B FFB2F7FF 681B4B06 B2D269BA
46C0739A B00446BD 46C0BD80 000003E0 00000400 10000398 B084B580 60F8AF00
607A60B9 4B10603B 0018447B FF96F7FF 210A68FB F7FF0018 68BBFFA3 0018210A
FF9EF7FF
447B4B09 F7FF0018 4B08FF87 68FA681B 4B07601A 68BA681B 46C0601A
B00446BD
46C0BD80 000003CC 000003D6 10000358 1000035C
'myuSec
B082B580 6078AF00 681B4B06 47982000 681B4B05 687B001A 47900018 46BD46C0
BD80B002
10000310 1000030C
'main
B087B590 60F8AF00 607A60B9 23F0603B 23F0617B 68BB613B 685B681A 680949A9
233AB2D2 68FB54CA 685B681A 680949A5 2338B2D2 687B54CA 685B681A 680949A1
2339B2D2 683B54CA 685B681A 6809499D 73CBB2D3 681B4B9B 739A2210 681B4B99
233A001A 009A5CD3 681B4B97 681A18D3 00DB2380 D00B429A 681B4B94 4B91001C
001A681B 5CD3233A 21082200 47A00018 681B4B8F 4B8B001A 0019681B 5CCB233A
00182106 4B874790 001A681B 5CD32338 4B85009A 18D3681B 2380681A 429A00DB
4B82D00B 001C681B 681B4B7E 2338001A 22005CD3 00182108 4B7D47A0 001A681B
681B4B78 23380019 21065CCB 47900018 681B4B74 2339001A 009A5CD3 681B4B72
681A18D3 00DB2380 D00B429A 681B4B6F 4B6C001C 001A681B 5CD32339 21082200
47A00018 681B4B6A 4B66001A 0019681B 5CCB2339 00182106 4B654790 001A681B
681B4B60 233A0019 21065CCB 47900018 00184B60 FF3EF7FF 681B4B5D 4B59001A
0019681B 5CCB233A 00182105 4B5A4790 F7FF0018 4B56FF2F 001A681B 681B4B51
233A0019 21065CCB 47900018 00184B53 FF20F7FF 681B4B4B 001A7BDB 40132301
4B4FD008 697A681B 4B4E601A 693A681B E007601A 681B4B4B 601A697A 681B4B48
601A693A 681B4B48 447A4A48 4B48601A 4A48681B 601A447A 447B4B47 F7FF0018
4B46FE6B 0018447B FE66F7FF 681B4B35 2338001A 210A5CD3 F7FF0018 4B40FE6F
0018447B FE58F7FF 447B4B3E F7FF0018 4B2CFE53 001A681B 5CD3233A 0018210A
FE5CF7FF
447B4B38 F7FF0018 4B37FE45 0018447B FE40F7FF 681B4B22 2339001A
210A5CD3 F7FF0018 4B31FE49 0018447B FE32F7FF 447B4B2F F7FF0018 4B21FE2D
681B681B 0018210A FE38F7FF 681B4B1C 210A681B F7FF0018 4B12FE31 7B9B681B
0018210A FE2AF7FF 681B4B0E 5C9A222C 5C59212D 430A0209 5C59212E 430A0409
5C5B212F 4313061B 0018210A FE16F7FF 447B4B19 F7FF0018 46C0FDFF B00746BD
46C0BD90 10000398 10000354 10000318 10000324 00002710 000186A0 00030D40
1000035C 10000358 10000348 FFFFFDA7 10000344 FFFFFD51 000001A2 000001AC
000001A4 0000019E 0000017E 0000018C 00000158 0000017A 000000F2 77617244
74636552 6C676E61 61432065 64656C6C 206F7420 20746573 6974704F 442E6E6F
4C505349 545F5941 20455059 00000000 00000A0D 77617244 6D746942 43207061
656C6C61 6F742064 74657320 65524820 6E612073 52562064 00207365 00000A0D
44414548 45545245 4C205453 4544414F 000A0D44 73726946 61702074 656D6172
20726574 0000203D 00000A0D 6F636553 7020646E 6D617261 72657465 00203D20
72696854 61702064 656D6172 20726574 0000203D 73655248 6552562C 49442C73
414C5053 59545F59 422C4550 68676972 73656E74 203D2073 43434700
End CSUB



/*
* File:   main.c

*/


/*
ArmmiteF4 compiler and linker command parameters
arm-none-eabi-gcc -c -mcpu=cortex-m4 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wall -Wno-main -ffunction-sections -O0 -fPIC -I. main.c -o main.o
arm-none-eabi-ld -nostartfiles -T arm-gcc-link.ld -o main.elf main.o

PicoMite compiler and linker command parameters
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
arm-none-eabi-ld -nostartfiles -T arm-gcc-link.ld -o main.elf main.o

*/
/* Uncomment the relevant  #define statement to use the required code   */
//#define ST7789
//#define QUICKSORT
//#define STRREV
#define HEADERTEST

/**********************************************/

#include "../inc/PicoCFunctions.h"
#ifdef HEADERTEST

void HEADERTEST_v100(){
 NOP();   //Padding to make sure it ends on 4 byte boundary
}


void p_string(const char *s){
   char  * testData    = ( char *)((void *)s );
   MMPrintString(testData);
}

void p_int(int a,int base){
   char b[64];
   IntToStr(b,a,base);
   MMPrintString(b);putConsole(32);
}

/********************************************************************
*  DrawRectangle in MMBasic is redirected to this function
* this is the basic drawing primitive used by most drawing routines
*    x1, y1, x2, y2 - the coordinates
*    c - the colour
* ------------------------------------------------------
* ***** MUST BE static void for the ARMMITEF4 **********
* ------------------------------------------------------
* *********************************************************************/
static void DrawRectangleSPI(int x1, int y1, int x2, int y2, int c){
static const char s4[]="DrawRectangle Called to set Option.DISPLAY_TYPE ";
static const char crlf[]="\r\n";
p_string(s4);p_int(c,10); p_string( crlf);
Option.DISPLAY_TYPE=c;

}

/********************************************************************
* DrawBitMap in MMBasic is redirected to this function
*   Prints the bitmap of a char
*    x, y - the top left of the char
*    width, height - size of the char's bitmap
*    scale - how much to scale the bitmap
*  fc, bc - foreground and background colour
*   bitmap - pointer to the bitmap
* ------------------------------------------------------
* ***** MUST BE static void for the ARMMITEF4 **********
* ------------------------------------------------------
* **********************************************************************/
static void DrawBitmapSPI(int x1, int y1, int width, int height, int scale, int fc, int bc, unsigned char *bitmap){
static const char s5[]="DrawBitmap Called to set HRes and VRes ";
static const char crlf[]="\r\n";
p_string(s5);p_int(x1,10);p_int(y1,10); p_string(crlf);
HRes=x1;
VRes=y1;

}

//workaround for uSec() issue. Hangs without putConsole()
void myuSec(unsigned int a){
putConsole(0);
uSec(a);
}

void main(long long *CD, long long *RST, long long *CS,long long *orientation){
    int HorizontalRes=240,VerticalRes=240;

    Option.LCD_Reset=*RST;
    Option.LCD_CD=*CD;
    Option.LCD_CS=*CS;
    Option.DISPLAY_ORIENTATION=*orientation;
    Option.DISPLAY_TYPE=USERLCDPANEL ;

    if(ExtCurrentConfig[(int) Option.LCD_Reset]!=EXT_BOOT_RESERVED){ExtCfg(Option.LCD_Reset,EXT_DIG_OUT,0);}
    //if(ExtCurrentConfig[(int) Option.LCD_Reset]!=EXT_BOOT_RESERVED){ExtCfg(Option.LCD_Reset,EXT_DIG_OUT,0);ExtCfg(Option.LCD_Reset,EXT_BOOT_RESERVED,0);}
    PinSetBit(Option.LCD_Reset, LATSET);

    if(ExtCurrentConfig[(int) Option.LCD_CD]!=EXT_BOOT_RESERVED){ExtCfg(Option.LCD_CD,EXT_DIG_OUT,0);}
    //if(ExtCurrentConfig[(int) Option.LCD_CD]!=EXT_BOOT_RESERVED){ExtCfg(Option.LCD_CD,EXT_DIG_OUT,0);ExtCfg(Option.LCD_CD,EXT_BOOT_RESERVED,0);}
    PinSetBit(Option.LCD_CD, LATSET);

    if(ExtCurrentConfig[(int) Option.LCD_CS]!=EXT_BOOT_RESERVED){ExtCfg(Option.LCD_CS,EXT_DIG_OUT,0);}
    //if(ExtCurrentConfig[(int) Option.LCD_CS]!=EXT_BOOT_RESERVED){ExtCfg(Option.LCD_CS,EXT_DIG_OUT,0);ExtCfg(Option.LCD_CS,EXT_BOOT_RESERVED,0);}
    PinSetBit(Option.LCD_CS, LATSET);



   //Reset the ST7789
   PinSetBit(Option.LCD_Reset,LATSET);myuSec(10000);
   PinSetBit(Option.LCD_Reset,LATCLR);myuSec(100000);
   PinSetBit(Option.LCD_Reset,LATSET);myuSec(200000);

   // spi_write_command(ST77XX_SWRESET);uSec(150000);
   // spi_write_command(ST77XX_SLPOUT);uSec(500000);

   // spi_write_command(ST77XX_COLMOD);spi_write_data(0x55);uSec(10000);


    if(Option.DISPLAY_ORIENTATION&1){
       VRes=HorizontalRes;
       HRes=VerticalRes;
    } else {
      HRes=HorizontalRes;
      VRes=VerticalRes;
   }


    //update original Vectors to point to our new functions

     //Set the DrawBitmap vector to point to our function
    // Called each time  the TEXT command writes a character
    DrawBitmapVector=(unsigned int)&DrawBitmapSPI;

    //Set the DrawRectangle vector to point to our function
    // Called when any of the GUI commands writes to screen.(Also CLS)
    DrawRectangleVector= (unsigned int)&DrawRectangleSPI;

    //CLS
    //DrawRectangle(0,0,HRes-1,VRes-1,0x000000);

    static const char startup[]="HEADERTEST LOADED\r\n";
    static const char crlf[]="\r\n";
    static const char s1[]="First parameter = ";
    static const char s2[]="Second parameter = ";
    static const char s3[]="Third parameter = ";

    static const char s6[]="HRes,VRes,DISPLAY_TYPE,Brightness = ";
    p_string(startup);
    p_string(s1); p_int(Option.LCD_CD,10);   p_string(crlf);
    p_string(s2);p_int(Option.LCD_Reset,10); p_string(crlf);
    p_string(s3); p_int(Option.LCD_CS,10);   p_string(crlf);
    p_string(s6); p_int(HRes,10);p_int(VRes,10);p_int(Option.DISPLAY_TYPE,10);p_int(Option.DefaultBrightness,10); p_string(crlf);

}

#endif



Here is a STMCubeIDE project I use to edit the main.c You can test compile and use the IDE. When error free I then use the recommend parameters and compile to generate the ELF and CSUB.

myPicoCSUBS.zip
Edited 2021-09-13 22:04 by disco4now
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 12:40pm 13 Sep 2021
Copy link to clipboard 
Print this post

Please could you see if this fixes the uSec issue


PicoMite.zip
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 548
Posted: 11:01pm 13 Sep 2021
Copy link to clipboard 
Print this post

No, does not fix it. Still hangs without the putConsole() work around.
Regards
Gerry
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 897
Posted: 07:49am 14 Sep 2021
Copy link to clipboard 
Print this post

@Peter,

A practical question.

MATH(MAX a()) gives the maximum value in the array. But is there any way to retrieve the index (pointer) at which the maximum is found ? This is of coarse tricky if it is a multi dimension array.
Actually, now I think of it, returning the pointer is even more logical than returning the value, since it is easy to read the value once you have the pointer. The opposite is not possible.

Regards,

Volhout
If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 10:22am 14 Sep 2021
Copy link to clipboard 
Print this post

PicoMiteV5.07.01b17.zip



Fixes a bug in the uSec function.
NB: the header file also needs changing

#define uSec(a)                         ((void  (*)(unsigned long long )) Vector_uSec) (a)


New optional parameter for the MATH(MIN and MATH(MAX functions

MATH(MAX array() [,index%])
MATH(MIN array() [,index%])


If index% is included in the function call then it will be updated with the index into the array that was the maximum or minimum. This only works for single dimension arrays. Attempting to use it on multidimensional arrays will give an error. index% must be an integer variable
Edited 2021-09-14 20:30 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 897
Posted: 10:54am 14 Sep 2021
Copy link to clipboard 
Print this post

Wow !
I was merely asking a question... And it is already invented and implemented !!
Tonight I will immediately implement it.

Thanks Peter !!!!
If nothing goes right ... turn left
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 548
Posted: 01:19pm 14 Sep 2021
Copy link to clipboard 
Print this post

Updated PicoCFunctions.h

uSec(a) macro updated as above to match bug fix for uSec function.
USERLCDPANEL  is now 17 to match latest firmware.

#define uSec(a)   (void  (*)(unsigned long long )) Vector_uSec) (a)
#define USERLCDPANEL   17



PicoCFunctions.zip

Peter,
Could the LCDPANEL USER display ID be moved up a few spots in the next update so it leaves a few spots and does not change when/if a new display is added.
uSec() seems to be good now.

Regards
Gerry
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 02:02pm 14 Sep 2021
Copy link to clipboard 
Print this post

  Quote  Could the LCDPANEL USER display ID be moved up a few spots in the next update so it leaves a few spots and does not change when/if a new display is added.


I'll move it to 25 in b18
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5328
Posted: 04:25pm 14 Sep 2021
Copy link to clipboard 
Print this post

PicoMiteV5.07.01b18.zip


User display is now #25 (untested)

setpin n,intl,myint now allowed on the touch irq pin when GUI functionality is not enabled. If the number of GUI controls is set to something other than 0 then use GUI INTERRUPT. In this case the setpin will error.

Additional parameter on PIO INIT
PIO INIT MACHINE pio%, statemachine%, clockspeed [,pinctrl] [,execctrl] [,shiftctrl][,startinstruction]


The startinstruction parameter tells the PIO which is the first instruction when PIO START is used (was previously always 0)

PIO EXECUTE need now only be used when you want to interrupt an existing program. It immediately terminates the currently executing instruction and starts running from the instruction specified
 
     Page 1 of 3    
Print this page
© JAQ Software 2021