Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:06 09 May 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 : Capturing 433MHz code on Picomite (Manchester code?)

Author Message
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 971
Posted: 05:21am 17 Sep 2022
Copy link to clipboard 
Print this post

Decoding 433MHz Signals -Picomite

These threads point to some previous work on decoding/sending via 433Mhz. See them for details of the actual protocols.
How can I capture this data-stream?(non-standard)
Switch ARLEC Remote Control Power Point
Decoding DIGOO remote temperature sensor

Peter @matherp developed the original CSub to capture the transition times of a signal arriving on the COUNT 1 pin.
A PicoMite CSUB to  timestamp pin changes (Manchester code?)

This posts details an extension of that CSub to allow some filtering of the data captured before it is passed to MMBasic to be decoded. This helps handle some of the spurious data generated by noise received by the 433MHz receiver.
The CSub and program can successfully receive codes from each of these devices.
Two versions of the ARLEC and an ebay 240V switch, a key fob and the DIGOO humidity and temperature sensor.






I used an RXB12 receiver which works at 3.3 volts. if you use one that requires 5v you will need a level shifter or voltage divided on the data line.




Setting CSUB Parameters to filter noise
The addition parameters on this new CSub are listed below, along with some hints on setting the values. The aim is to have the CSub discard as much noise as possible before sending an interrupt to MMBasic for it to decode the data captured.


' This CSUB logs activity on GP6 the COUNT1 pin., each transition of the pin is
' logged to the nearest microsecond. The timestamp is positive for positive
' going transitions and negated for negative going ones
' LOG mode,times(),samples,minsamples,timeout,startmin,startmax,runtsize
' The parameters are:
' mode     : 1 to enable, 0 to disable
' times()  : an integer array to hold the timestamps
' samples  : an integer with the number of samples to capture (the array must be at least this big)
' minsamples :an integer with minimum no of valid transitions after a start before its considered valid
' timeout  :an integer giving a timeout in microseconds for the CSUB to terminate
'          :if the number of sample requested is not reached. 0 for no timeout period.
' startmin : minimum transition in uSec that will be considered as a valid start pulse
' startmax : maximum transition in uSec that will be considered as a valid start pulse
' runtsize : minimum transition in uSec that will be considered as a valid data
'
' A valid start is a transition > startmin and < startmax and is a positive going transition.
' If during the capture after a valid start is detected another start is detected before minsamples is
' reached then this is considered noise and the capture will restart.
' A transition less that runtsize will be considered noise and restart the capture.
' A transistion greater that startmax is considered noise and will restart the capture.
' These can be tuned to eliminate false captures due to noise.
' When either the timeout(if enabled) occurs or the number of samples is reached the
' CSUB triggers an interrupt so the Basic program can then analyse the captured data.






The MMBasic Code




'================================================================================================
' Set the correct COUNT1 pin
'================================================================================================
 SETPIN GP6,CIN,5 'set COUNT1 pin 9 (GP6) to cause a H/W interrupt on both edges
'
OPTION EXPLICIT

''CSUB Parameter values


DIM INTEGER times(100)     'array to receive the timestamps
DIM INTEGER samples=80     'number of transitions to receive
DIM INTEGER minsamples=40  'min number of transitions between successive start pulses
DIM INTEGER timeout=0      'timeout of the CSUB in microseconds, 0 is no timeout
DIM INTEGER startmin=4800  'minimum length of start signal in uS
DIM INTEGER startmax=11620 'maximum length of start signal in uS
DIM INTEGER runtsize=130    'minimum size for valid transition in uS
DIM INTEGER gotInterrupt=0
'================================================================================================
' Data Variables
'================================================================================================

DIM DEVICE$
DIM INTEGER ttime,threshold,i,codetype,reqsize,delimitvalue,size
'================================================================================================
' Program Initialization
'================================================================================================
OPTION BREAK 4
ON KEY 3, exitint
PRINT "CNTRL D to Break !!!"
PRINT "CNTRL C to end nicely"

Interrupt myint 'set up an interrupt that can be triggered by the CSUB
'
'Print chr$(27)+"[2J";              ' CLS VT100

'================================================================================================
' Load the CSUB to capture and record time between transitions on COUNT1 pin
'================================================================================================
LOG 1,times(),samples,minsamples,timeout,startmin,startmax,runtsize  'initialise the logging

DO
     IF gotInterrupt THEN
     Decode
     gotInterrupt=0
     'restart the CSUB capture
     LOG 1,times(),samples,minsamples,timeout,startmin,startmax,runtsize 'initialise the logging
   END IF
LOOP

'subroutine that is triggered when the non-blocking CSUB has data or times out
SUB myint
 gotInterrupt=1
END SUB

'subroutine to cleanly stop after CNTRL+C ON KEY.
'CNTRL+C is set as the break key again
'The CSUB can't be unloaded, but is told to stop logging.
SUB exitint
 OPTION BREAK 3
 'stop the CSUB capture
 LOG 0,times(),samples,minsamples,timeout,startmin,startmax,runtsize 'Disable the logging
 ? "Ended cleanly with CNTRL C "
 END
END SUB

SUB Decode()
'Start pulse is the first sample
ttime=times(0)
IF ttime<0 THEN
 ? "NEGATIVE",ttime
 EXIT SUB
ENDIF
'The length of the start pulse is used identify the likely code type
SELECT CASE ttime
 CASE > 11620
     CODETYPE=0
     REQSIZE=99
     '? "too big",ttime,;
     DEVICE$="TOOLONG"
 CASE > 11000
    REQSIZE=49
    CODETYPE=1
    '? "KEYFOB",ttime,;
    DEVICE$="KEYFOB"
 CASE > 10000
     REQSIZE=67
     CODETYPE=1
    '? "ARLEC",ttime,;
    DEVICE$="ARLEC"
 CASE > 8800
     REQSIZE=75  
     CODETYPE=2
    '? "DIGOO",ttime,;
    DEVICE$="DIGOO"
 CASE > 7800
    REQSIZE=65
    CODETYPE=1
    '? "ARLEC2",ttime,;
    DEVICE$="ARLEC2"
 CASE > 5200
   REQSIZE=100
   CODETYPE=0
    '? "ROGUE",ttime,;
    DEVICE$="UNKNOWN"          
 CASE > 4800
   REQSIZE=49
   CODETYPE=1
    '? "EBAY",ttime,;        '49
    DEVICE$="EBAY"  
 CASE ELSE
    CODETYPE=0
    REQSIZE=98
   '? "too small",ttime,;
   DEVICE$="TOOSMALL"
END SELECT

' find  end of a (possibly) valid code segment by looking for next start pulse
' use 3/4 of the start pulse as threshold for the end pulse
threshold=3*ttime/4
'Search for next start pulse
i=1
DO WHILE times(i)<(threshold)
  i=i+1
  IF i = 100 THEN EXIT DO
LOOP
size=i-1
IF size<REQSIZE THEN
  ' ?
  '? "RUNT --- discarded  by MMbasic",size
  'i=0
  'Do While times(i)
   '? times(i),i
   'i=i+1
  'Loop
ELSE
 '? "----GOOD--------",size
 ' i=0
 ' Do While times(i)
 '  ? times(i),i
 '  i=i+1
 ' Loop
 ' ? "---------------------"
 IF codetype=0 THEN PRINT "CODE0 Invalid SIZE",size,REQSIZE,device$,ttime
 IF codetype=1 THEN DecodeType1 size,times()
 IF codetype=2 THEN DecodeType2 size,times()
ENDIF
END SUB

'Decodes manchester code for 1=short,long      0=long,short
SUB DecodeType1(size AS INTEGER,b%())
 IF size=67 THEN size=65  'longer ARLEC code is just stop bits, so ignore them
 IF size<>49 AND size<>65 AND size<> 49 THEN
   ? "Invalid size --- ",size,device$
   EXIT SUB
 ENDIF  
 LOCAL INTEGER c%(size-1),code%=0
 LOCAL first$,second$
 ' Copy all values less the start into an new array
 FOR i=0 TO size-1
   c%(i)=ABS(b%(i+1))
 NEXT i
 delimitvalue = MATH(MEAN c%())
 '? delimitvalue
 'The basis of the code is 0 = 1 short pulse + 1 long pulse and
 '1= 1 long pulse + 1 short pulse
 'A long pulse is 3 times the length of a short pulse.
 FOR i=0 TO size-2 STEP 2
   IF c%(i)< delimitvalue THEN first$="0" ELSE first$="1"
   IF c%(i+1)< delimitvalue THEN second$="0" ELSE second$="1"
   SELECT CASE first$+second$
     CASE "01"
       code%=code%<<1
       '?  "0";
     CASE "10"
        code%=code%<<1 OR 1
       ' ? "1";
     CASE ELSE
       '? "X";
   END SELECT
 NEXT i
 ? DEVICE$,BIN$(code%,(size-1)\2)
END SUB

'Decodes DIGDOO 74 bit code  Only odd bits contain code. Even bits can be ignored
SUB DecodeType2(size AS INTEGER,b%())
 IF size<>75 THEN
   ? "Invalid size --- ",size,device$
   EXIT SUB
 ENDIF  
 LOCAL INTEGER newsize  
 newsize=size-1
 newsize=newsize\2
 LOCAL INTEGER c%(newsize-1),code%=0
 LOCAL first$,second$
 ' Copy all odd values less the start into an new array
 FOR i=0 TO newsize-1
   c%(i)=ABS(b%(2*i+2))
 NEXT i
 delimitvalue = MATH(MIN c%())+((MATH(MAX c%())-MATH(MIN c%()))/2)
 '? "DELIMIT",delimitvalue
 
 FOR i=0 TO newsize-1
   IF c%(i)< delimitvalue THEN first$="0" ELSE first$="1"
   SELECT CASE first$
     CASE "0"
       code%=code%<<1
     CASE "1"
       code%=code%<<1 OR 1
     CASE ELSE
       '? "X";
   END SELECT
 NEXT i
  ? device$,BIN$(code%,(newsize))
END SUB

'
' This CSUB logs activity on GP6 the COUNT1 pin., each transition of the pin is
' logged to the nearest microsecond. The timestamp is positive for positive
' going transitions and negated for negative going ones
' LOG mode,times(),samples,minsamples,timeout,startmin,startmax,runtsize
' The parameters are:
' mode     : 1 to enable, 0 to disable
' times()  : an integer array to hold the timestamps
' samples  : an integer with the number of samples to capture (the array must be at least this big)
' minsamples :an integer with minimum no of valid transitions after a start before its considered valid
' timeout  :an integer giving a timeout in microseconds for the CSUB to terminate
'          :if the number of sample requested is not reached. 0 for no timeout period.
' startmin : minimum transition in uSec that will be considered as a valid start pulse
' startmax : maximum transition in uSec that will be considered as a valid start pulse
' runtsize : minimum transition in uSec that will be considered as a valid data
'
' A valid start is a transition > startmin and < startmax and is a positive going transition.
' If during the capture after a valid start is detected another start is detected before minsamples is
' reached then this is considered noise and the capture will restart.
' A transition less that runtsize will be considered noise and restart the capture.
' A transistion greater that startmax is considered noise and will restart the capture.
' These can be tuned to eliminate false captures due to noise.
' When either the timeout(if enabled) occurs or the number of samples is reached the
' CSUB triggers an interrupt so the Basic program can then analyse the captured data.

'use this CSUB for 50705 Beta13 onwards
CSUB LOG
0000009B
'PICO_PIN9_GP6_INTPROG
AF00B580 46BD46C0 0000BD80
'check_timer
B082B580 4B13AF00 3350681B 687B607B 685B681A 43190011 4B0FD017 4798681B
681A687B 4299685B D10ED803 D8004290 4B0AE00B 2200681B 4B09601A 2200681B
4B08601A 2201681B 46C0601A B00246BD 46C0BD80 1000038C 100003AC 10000388
100003C8 100003D0
'intprog
B091B590 4B76AF00 3360681B 4B7463FB 3370681B 4B7263BB 3380681B 4B70637B
3390681B 4B6E633B 33A0681B 4B6C62FB 62BB681B 681B4B6A 627B3310 681B4B68
623B3320 681B4B66 61FB3330 681B4B64 61BB3340 681B6ABB 6A3B617B 2B00681B
6AF9DC10 23002200 604B600A 681B4B5D 601A2200 681B4B5C 601A2200 681B4B5B
601A2201 681B4B5A 00024798 60BA000B 6AFB60FB 685B681A 43190011 6BF9D10A
68FB68BA 604B600A 22016AF9 600A2300 E092604B 681A6BFB 68B8685B 1A8068F9
00024199 603A000B 6BF9607B 68FB68BA 604B600A 681A6BBB 6879685B D3114299
42996879 6839D102 D30B4291 681A6B3B 6879685B D8054299 42996879 6839D110
D90D4291 681A69FB 601A6A3B 681A6A7B 601A6ABB 22016AF9 600A2300 E05C604B
681A6B7B 6879685B D8054299 42996879 6839D121 D91E4291 681A6A3B 681969FB
681B69BB 429A1ACB 6AF9DD04 23002201 604B600A 681A6A3B 681B69FB D10A429A
681B4B24 47982009 D0041E03 22026AF9 600A2300 6AFB604B 685B681A DC0B2B00
2A01D101 69FBD808 6A3B681A 6A7B601A 6ABB681A E020601A 681B4B16 47982009
D0051E03 683A6979 600A687B E009604B 687B683A 42502100 697C4199 000B0002
60636022 681B6ABB 001A3308 601A6ABB 681B6A3B 6A3B1E5A 46BD601A BD90B011
1000038C 10000388 100003C8 100003D0 100003AC 1000032C
'main
B090B580 60F8AF00 607A60B9 68FB603B 685B681A D10C2A01 D10A2B00 681B4B4A
447A4A4A 4B4A601A 4A4A681B 601A447A 4B45E007 2200681B 4B45601A 2200681B
4B45601A 63FB681B 681B4B43 63BB3310 6BFB68BA 68BA601A 601A6BBB 681B4B3E
637B3320 681B4B3C 633B3340 681B4B3A 62FB3330 681A687B 6B7B685B 683B601A
685B681A 601A6B3B 681A687B 6AFB685B 4B31601A 33A0681B 6AB962BB 23002200
604B600A 681B4B2C 627B3380 681A6CFB 6A7B685B 4B28601A 3390681B 6D3B623B
685B681A 601A6A3B 681B4B23 61FB3370 681A6D7B 69FB685B 4B1F601A 33B0681B
6CBB61BB 685B681A 600A69B9 4B1A604B 3360681B 6979617B 23002200 604B600A
681B4B15 613B3350 681A69BB 0011685B D1094319 22006939 600A2300 4B0A604B
2200681B E00A601A 681B4B0C 69BB4798 685B681A 414B1812 600A6939 46C0604B
B01046BD 46C0BD80 10000388 FFFFFD7B 100003C8 FFFFFDD9 1000038C 100003AC
END CSUB

'use this CSUB for PRE 50705 Beta13
CSUB LOGPRE50705BETA13
0000009B
'PICO_PIN9_GP6_INTPROG
AF00B580 46BD46C0 0000BD80
'check_timer
B082B580 4B13AF00 3350681B 687B607B 685B681A 43190011 4B0FD017 4798681B
681A687B 4299685B D10ED803 D8004290 4B0AE00B 2200681B 4B09601A 2200681B
4B08601A 2201681B 46C0601A B00246BD 46C0BD80 10000388 100003A8 10000384
100003C4 100003CC
'intprog
B091B590 4B76AF00 3360681B 4B7463FB 3370681B 4B7263BB 3380681B 4B70637B
3390681B 4B6E633B 33A0681B 4B6C62FB 62BB681B 681B4B6A 627B3310 681B4B68
623 61FB3330 681B4B64 61BB3340 681B6ABB 6A3B617B 2B00681B
6AF9DC10 23002200 604B600A 681B4B5D 601A2200 681B4B5C 601A2200 681B4B5B
601A2201 681B4B5A 00024798 60BA000B 6AFB60FB 685B681A 43190011 6BF9D10A
68FB68BA 604B600A 22016AF9 600A2300 E092604B 681A6BFB 68B8685B 1A8068F9
00024199 603A000B 6BF9607B 68FB68BA 604B600A 681A6BBB 6879685B D3114299
42996879 6839D102 D30B4291 681A6B3B 6879685B D8054299 42996879 6839D110
D90D4291 681A69FB 601A6A3B 681A6A7B 601A6ABB 22016AF9 600A2300 E05C604B
681A6B7B 6879685B D8054299 42996879 6839D121 D91E4291 681A6A3B 681969FB
681B69BB 429A1ACB 6AF9DD04 23002201 604B600A 681A6A3B 681B69FB D10A429A
681B4B24 47982009 D0041E03 22026AF9 600A2300 6AFB604B 685B681A DC0B2B00
2A01D101 69FBD808 6A3B681A 6A7B601A 6ABB681A E020601A 681B4B16 47982009
D0051E03 683A6979 600A687B E009604B 687B683A 42502100 697C4199 000B0002
60636022 681B6ABB 001A3308 601A6ABB 681B6A3B 6A3B1E5A 46BD601A BD90B011
10000388 10000384 100003C4 100003CC 100003A8 10000328
'main
B090B580 60F8AF00 607A60B9 68FB603B 685B681A D10C2A01 D10A2B00 681B4B4A
447A4A4A 4B4A601A 4A4A681B 601A447A 4B45E007 2200681B 4B45601A 2200681B
4B45601A 63FB681B 681B4B43 63BB3310 6BFB68BA 68BA601A 601A6BBB 681B4B3E
637B3320 681B4B3C 633B3340 681B4B3A 62FB3330 681A687B 6B7B685B 683B601A
685B681A 601A6B3B 681A687B 6AFB685B 4B31601A 33A0681B 6AB962BB 23002200
604B600A 681B4B2C 627B3380 681A6CFB 6A7B685B 4B28601A 3390681B 6D3B623B
685B681A 601A6A3B 681B4B23 61FB3370 681A6D7B 69FB685B 4B1F601A 33B0681B
6CBB61BB 685B681A 600A69B9 4B1A604B 3360681B 6979617B 23002200 604B600A
681B4B15 613B3350 681A69BB 0011685B D1094319 22006939 600A2300 4B0A604B
2200681B E00A601A 681B4B0C 69BB4798 685B681A 414B1812 600A6939 46C0604B
B01046BD 46C0BD80 10000384 FFFFFD7B 100003C4 FFFFFDD9 10000388 100003A8
END CSUB





The C source code



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

//#include "PicoCFunctions.h"
// uSecTimer returns a 64-bit integer giving the number of microseconds since system boot
// CFuncRam is 256 bytes of RAM that aren't touched by Basic
// PinRead gives the status of a pin specified by the number (pin9 = GP6)
// CFuncInt1 is the address of a function to be called when a H/W interrupt occurs on COUNT pin 1
// CFuncmSec is the address of a function to be called every millisecond by the main clock interrupt
// Interrupt is a variable that tells Basic that the INTERRUPT specified in the Basic code has been triggered
//

#define COUNT1 9        //The COUNT1 pin on the Picomite
void PICO_PIN9_GP6_INTPROG(){
}

#define ARRAY           0
#define ARRAYSAVE       4
#define COUNT 8
#define COUNTSAVE 12
#define COUNTMIN        16
#define ENDTIME   20
#define LASTTIME 24
#define RUNTSIZE 28
#define STARTSIZE 32
#define STARTSIZEMAX 36
#define RUNNING         40
#define TIMEOUT 44

static void check_timer(void){ //routine called every millisecond

  unsigned long long int *endtime=(unsigned long long int *)&CFuncRam[ENDTIME];

  if(*endtime!=0 && uSecTimer()>*endtime){ //  timeout triggered
    CFuncmSec=0; //disable the millisecond interrupt
    CFuncInt1=0; //disable the H/W pin change interrupt
    Interrupt=1; //trigger the Basic interrupt
  }
}

static void intprog(void){ //routine called every change on GP6
  unsigned long long int *lasttime=( unsigned long long int *)&CFuncRam[LASTTIME];
  long long int *runtsize=( long long int *)&CFuncRam[RUNTSIZE];
  long long int *startsize=( long long int *)&CFuncRam[STARTSIZE];
  long long int *startsizemax=( long long int *)&CFuncRam[STARTSIZEMAX];
  long long int *running=( long long int *)&CFuncRam[RUNNING];

  unsigned long long int nowusec;
  unsigned long long int thisusec;
  unsigned int *array=(unsigned int *)&CFuncRam[ARRAY];
  unsigned int *arraysave=(unsigned int *)&CFuncRam[ARRAYSAVE];
  int *count=(int *)&CFuncRam[COUNT];
  int *countsave=(int *)&CFuncRam[COUNTSAVE];
  int *countmin=(int *)&CFuncRam[COUNTMIN];
  unsigned int d=*array;

  if(*count<=0){ //count satisfied
*running=0;
    CFuncmSec=0; //disable the millisecond interrupt
    CFuncInt1=0; //disable the H/W pin change interrupt
    Interrupt=1; //trigger the Basic interrupt

  }
  nowusec=uSecTimer();
  if (*running==0){
  *lasttime=nowusec;
  *running=1;
  return;
  }
  thisusec=nowusec-*lasttime;
  *lasttime=nowusec;
  //If we have a runt or start pulse is too ling then start again
  if (thisusec<*runtsize || thisusec>*startsizemax){
  *count=*countsave;
  *array=*arraysave;
  *running=1;
  return;
  }
  if (thisusec>*startsize){                                  //We have a start pulse
  if (*count>(*countsave-*countmin))*running=1;          // if is not the first and we have not reached countmin then abort.
  if (*count==*countsave && PinRead(COUNT1))*running=2;  //Its the first one and its +ve So we are now capturing !!!
  }
  if (*running<2){   //Restart the capture. Reset count and array and then look for a new start pulse.
    *count=*countsave;
    *array=*arraysave;
    return;
  }
  // Record the transition time of the count1 pin to the array.
  if(PinRead(COUNT1))*(long long int *)d=thisusec;
  else *(long long int *)d=-thisusec;

  *array=*array+sizeof(long long int);
  *count=*count-1; //decrement the event counter
}


void main(long long int *mode,long long int *basicarray, long long int *samplecount, long long int *samplecountmin,long long int *timeoutms,long long int *startmin,long long int *startmax,long long int *runt){

if (*mode==1){
 CFuncmSec=(unsigned int)&check_timer; //Set up the address for the millisecond timer
 CFuncInt1=(unsigned int)&intprog; //set up the address for the H/W interrupt
}else{
 CFuncmSec=0;          //clear the address for the millisecond timer
 CFuncInt1=0;           //clear the address for the H/W interrupt
}
 unsigned int *array=(unsigned int *)&CFuncRam[ARRAY]; //get a pointer to a permanent location to store a global pointer to the array
 unsigned int *arraysave=(unsigned int *)&CFuncRam[ARRAYSAVE];
 *array=(unsigned int)basicarray;
 *arraysave=(unsigned int)basicarray;

 int *count=(int *)&CFuncRam[COUNT]; //get a pointer to a permanent location to store the count of the samples required
 int *countmin=(int *)&CFuncRam[COUNTMIN]; //get a pointer to a permanent location to store the count of the minimum samples required
 int *countsave=(int *)&CFuncRam[COUNTSAVE];
 *count=(int)*samplecount;
 *countmin=(int)*samplecountmin;
 *countsave=(int)*samplecount;

 long long int *running=( long long int *)&CFuncRam[RUNNING];
 *running=0;

 int *startsize=( int *)&CFuncRam[STARTSIZE];//get a pointer to a permanent location to store the startsize of the calls made
 *startsize=(int)*startmin;
 int *startsizemax=( int *)&CFuncRam[STARTSIZEMAX];//get a pointer to a permanent location to store the startsizemax of the calls made
 *startsizemax=(int)*startmax;
 int *runtsize=( int *)&CFuncRam[RUNTSIZE];//get a pointer to a permanent location to store the callcount of the calls made
 *runtsize=(int)*runt;

 unsigned long long int *timeout=( unsigned long long int *)&CFuncRam[TIMEOUT]; //get a pointer to a permanent location to store the timeout value
 *timeout=( unsigned long long int)*timeoutms;

 unsigned long long int *lasttime=(unsigned long long int *)&CFuncRam[LASTTIME]; //get a pointer to a permanent location to store the lasttime value
// *lasttime=uSecTimer();
 *lasttime=0;

 unsigned long long int *endtime=(unsigned long long int *)&CFuncRam[ENDTIME]; //get a pointer to a permanent location to store the endtime value
 if (*timeout==0){
 *endtime=0;
 CFuncmSec=0;          //clear the address for the millisecond timer as it not needed
 }else{
    *endtime=uSecTimer()+ *timeout;
 }

}


Latest F4 Latest H7 FotS
 
electricat

Senior Member

Joined: 30/11/2020
Location: Lithuania
Posts: 293
Posted: 06:06am 17 Sep 2022
Copy link to clipboard 
Print this post

Missed this. Very interesting!
Thx
My MMBasic 'sand box'
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6218
Posted: 09:49pm 18 Sep 2022
Copy link to clipboard 
Print this post

Gerry,
Peters original code won't even load with the current Version of MMBasic.
With your expanded version the checking stops me from using it.

Could you re-compile Peters original for the later MMBasic versions?

I must work out how to do it for myself one day.

Jim
VK7JH
MMedit
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2414
Posted: 10:46pm 18 Sep 2022
Copy link to clipboard 
Print this post

I had been using it on previous versions but now get this:-

Saved 1979 bytes
> RUN
Error: Invalid address - resetting
PicoMiteVGA MMBasic Version 5.07.05b18
Copyright 2011-2022 Geoff Graham
Copyright 2016-2022 Peter Mather

>

Edit
Perhaps it is related to a little quirk it has. I can't find a way out of:-

Sub myint 'subroutine that is triggered when the non-blocking CSUB terminates

End Sub should do it but doesn't.


Edit 2
Now the immediate mode line editing is not quite right. Pressing the up arrow moves the cursor down to the next line with no ">". Pressing enter runs the last line even though no command is showing.

> ? time$    <----typed time$ enter
09:44:57
> ? time$    <----pressed up arrow
              <----pressed enter                                                                                                            
09:45:11
>

Re flashing doesn't fix it, unless the Pico is 'nuked' first.
Edited 2022-09-19 09:46 by phil99
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 971
Posted: 12:10am 19 Sep 2022
Copy link to clipboard 
Print this post

The address of the calltable changed with v5.07.05 Beta13  when Peter started with the later compiler, so picoCFunctions.h had this change.

//Addresses in the API Table for the pointers to each function
//#define BaseAddress   0x1000030C
#define BaseAddress   0x10000310

So any CSUB that calls any internal functions will need to be recompiled if used on Beta13 onward, otherwise expect strange things.

I have put a recompiled version on Peters CSUB in the original thread.

Gerry
Latest F4 Latest H7 FotS
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2414
Posted: 12:46am 19 Sep 2022
Copy link to clipboard 
Print this post

Thank you, much appreciated.
Phil

Edit
Something still not right with the new one.

Saved 2243 bytes
> RUN
Error: Invalid address - resetting
PicoMite MMBasic Version 5.07.05b18
Copyright 2011-2022 Geoff Graham
Copyright 2016-2022 Peter Mather
Edited 2022-09-19 11:54 by phil99
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 971
Posted: 12:13pm 19 Sep 2022
Copy link to clipboard 
Print this post

I have updated again, I ran on Beta18 and seems OK now.
Latest F4 Latest H7 FotS
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2414
Posted: 01:08pm 19 Sep 2022
Copy link to clipboard 
Print this post

"I have updated again, I ran on Beta18 and seems OK now."

Yes it is, thanks once again.
 
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