Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:14 18 May 2024 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 Alpha Firmware

     Page 13 of 17    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 09:52pm 09 Jun 2021
Copy link to clipboard 
Print this post

a24


PicomiteV5.07.00a24.zip

UARTS now working COM0 with UART0TX/RX and COM1 with UART1TX/RX - minimal testing

e.g connect pin 1 to pin 12, connect pin 2 to pin 11


setpin 11,uart1tx:setpin 12,uart1rx:open "com1:115200" as #1
setpin 1,uart0tx:setpin 2,uart0rx: open "com0:115200" as #2
print #1, "Hello world"
print input$(100,2)
print #2, "Bye world"
print input$(100,1)
close 1
close 2

Edited 2021-06-10 07:53 by matherp
 
led-bloon

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 204
Posted: 10:21pm 09 Jun 2021
Copy link to clipboard 
Print this post

FYI
  Quote  There's no linux for the Pico (yet)

Not true, as there is Fuzix. Read about it, starting at:
Fuzix Info
Close to the bottom of the page.  Amazing...
led
Miss you George
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 10:39pm 09 Jun 2021
Copy link to clipboard 
Print this post

  atmega8 said  is there any documentation for the picomite?

Perhaps the closest there is to documentation for the picomite is the manual for the Armmite F4.

But this is an alpha release, very much a work in progress, and many things in the F4 manual are not implemented, and some may never be.

Other things, like the setting up of the pins for SPI, I2C, and Com ports and for an LCD (not yet implemented) are different, and are documented only in this thread and perhaps here.

For the Micromite Summary page, start here.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 11:23pm 09 Jun 2021
Copy link to clipboard 
Print this post

Success with Tx looped back to Rx:

> list
Dim string cr=Chr$(13), lf=Chr$(10)
a$="A wonderful bird is the pelican,"+cr+lf+"His bill will hold more than his b
elly can,"+cr+lf
b$="He can take in his beak"+cr+lf+"Enough food for a week"+cr+lf+"But I'm damn
ed if I see how the helican!"
SetPin 1,uart0tx:SetPin 2,uart0rx: Open "com0:115200" As #1
Print #1,a$;b$
Pause 100
Print Input$(255,#1)
Close #1
> RUN
A wonderful bird is the pelican,
His bill will hold more than his belly can,
He can take in his beak
Enough food for a week
But I'm damned if I see how the helican!


But . . .

> SetPin 1,uart0tx:SetPin 2,uart0rx: Open "com0:115200" As #1
> print #1,"ABC"
> ?loc(#1)
Error : Internal fault (sorry)
>


~
Edited 2021-06-10 09:59 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5770
Posted: 06:34am 10 Jun 2021
Copy link to clipboard 
Print this post

  led-bloon said  FYI
  Quote  There's no linux for the Pico (yet)

Not true, as there is Fuzix. Read about it, starting at:
Fuzix Info
Close to the bottom of the page.  Amazing...
led

I stand corrected! Oh yes, that's rather neat. :)
I think it's one of those "Why? To see if it could be done, of course!" projects. lol

Picomite info:
I'm slowly adding bits to this as we go along. I'm not pretending that it's a manual, but more of a precis of what's been done. I've not added the UART stuff yet, so more updates shortly.
Picomite doc a22.zip
.
.
Edited 2021-06-10 16:39 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 07:14am 10 Jun 2021
Copy link to clipboard 
Print this post

a25



PicomiteV5.07.00a25.zip
 

Fixes LOF, LOC and EOF


This is the last update until later next week
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5770
Posted: 07:22am 10 Jun 2021
Copy link to clipboard 
Print this post

Thank you for all your hard work, Peter. You're a star!  

Now we have a few days respite from updating to concentrate on breaking it...  


A bit of a quick update to this as well, while I'm here...
Picomite doc a25.zip
.
.
Edited 2021-06-10 17:46 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3589
Posted: 08:18am 10 Jun 2021
Copy link to clipboard 
Print this post

I am a few versions behind (a23) but as promised, a test of the fft function.



I expect this to be the correct result, at least I see the fundamental frequency and harmonics. The fact that the fft output is symetrical, when most applications only show half of the fft as a spectrum.
I am not sure if the centre peaks in the fft graph are result of the start and stop of the sine wave in the input signal.

Anyway, MATH FFT MAGNITUDE works.

This is the code I used for testing.
'GFXterm - magnitude FFT

'init gfxterm parameters
Const GFX=Chr$(16)
Const ENQ=Chr$(5)
Const ACK=Chr$(6)
Print GFX "?"
Input Gw, Gh
Print GFX "clear" 0, 0, Gw, Gh
GoSub drw

'defines
n=1023   'samples for fft (multiple of 2 - 1)
cy = 20  'cycles of sinewave in n samples

Dim a!(n),fm!(n)
GoSub sinfill
GoSub sinshow

Math fft magnitude a!(),fm!()

GoSub fftshow

End

'show fft on graphics terminal
fftshow:
 Print GFX "ink" 255, 255, 0, 2
 'scan magnitude array
 mi!=0:ma!=0
 For i=0 To n
   mi!=Min(mi!,fm!(i))
   ma!=Max(ma!,fm!(i))
 Next i
'  Print mi!, Ma!
 ygain=-Gh/(3*(ma!-mi!))
 yoffset=Gh-1
 xgain=Gw/(n+1)
 xoffset=0
 For i=0 To n-1
   x1=i*xgain+xoffset
   x2=(i+1)*xgain+xoffset
   y1=fm!(i)*ygain+yoffset
   y2=fm!(i+1)*ygain+yoffset
   Print GFX "line" x1,y1,x2,y2
 Next i
Return

'fill input array a()
sinfill:
For i=0 To n
 a!(i)=Sin(i*2*Pi*cy/n)
'  Print a!(i),
Next i
Return

'show the graph of the input signal
sinshow:
 Print GFX "ink" 255, 255, 0, 2
 ygain=-Gh/5
 yoffset=Gh/4
 xgain=Gw/(n+1)
 xoffset=0
 For i=0 To n-1
   x1=i*xgain+xoffset
   x2=(i+1)*xgain+xoffset
   y1=a!(i)*ygain+yoffset
   y2=a!(i+1)*ygain+yoffset
   Print GFX "line" x1,y1,x2,y2
 Next i
Return

'draw frames
drw:
 Print GFX "ink" 255, 255, 255, 2
 Print GFX "line" 0,Gh,0,Gh/2+1
 Print GFX "line" 0,Gh,Gw,Gh
 Print GFX "line" 0,Gh/2+1,Gw,Gh/2+1
 Print GFX "line" Gw,Gh,Gw,Gh/2+1
 Print GFX "line" 0,0,0,Gh/2-1
 Print GFX "line" 0,0,Gw,0
 Print GFX "line" 0,Gh/2-1,Gw,Gh/2-1
 Print GFX "line" Gw,0,Gw,Gh/2-1
Return

PicomiteVGA PETSCII ROBOTS
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 12:04pm 10 Jun 2021
Copy link to clipboard 
Print this post

  matherp said  This is the last update until later next week

Now I have no excuse to put off further weeding around and trimming the thorny flowering quince.

Thanks, Peter--very much enjoying this journey.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 504
Posted: 06:13pm 10 Jun 2021
Copy link to clipboard 
Print this post

@volhout : wat is this graphical terminal and how to use it?
Plasma
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 504
Posted: 06:14pm 10 Jun 2021
Copy link to clipboard 
Print this post

@volhout : wat is this graphical terminal and how to use it?
Plasma
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5770
Posted: 08:08pm 10 Jun 2021
Copy link to clipboard 
Print this post

I'm trying to verify Peter's demo for the UART setup but  can't get it to work. I'm using different pins for UART0 (my SD card is using those), but in theory that shouldn't matter. Would someone like to check my setup please?

'UART test
'link 16-12 and 17-11

SetPin 16, uart0tx
SetPin 17, uart0rx
Open "com0:115200" As #1

SetPin 11, uart1tx
SetPin 12, uart1rx
Open "com1:115200" As #2

Print #1,"Hello World!"
Print Input$(100,2)

Print #2,"Bye World!"
Print Input$(100,1)

Close 1
Close 2

If I put an LED on the TX pins it flashes on transmit (I suppose!).
Edited 2021-06-11 06:18 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 08:26pm 10 Jun 2021
Copy link to clipboard 
Print this post

I'm away from my pico at present, but does loopback work on each?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5770
Posted: 08:41pm 10 Jun 2021
Copy link to clipboard 
Print this post

Ah... I didn't try that. lol
Not clear...  With the prog as shown, linking 16-17 I get "Hel"  :)
Commenting out everything to do with UART1 that reduces to "He"

UART1 doesn't seem to be working at all.

Might be an overclocking thing. It's no hassle - I'll have more time to play late tomorrow afternoon. Just seems odd.

Looks like something to do with timing.
option cpuspeed 150000
baud rate at 115200 I get "Hell" but nothing from UART1
reduce baud rate to 1200 and I get nothing from either
put it back to 115200 and got "Hello" the first time (then back to "Hell").

Oh - this is a25, by the way.

Another edit:
Got it working.
option cpuspeed 250000
Had to add PAUSE 1 after each PRINT#n statement otherwise I got nothing. Also tried PAUSE 0.5 and PAUSE 0.8 but neither was ok.
Edited 2021-06-11 07:12 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 09:43pm 10 Jun 2021
Copy link to clipboard 
Print this post

  Quote  Had to add PAUSE 1 after each PRINT#n statement otherwise I got nothing.


Print is non-blocking. If you do input immediately after the print then the data hasn't had a chance to be transmitted let alone arrive
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5770
Posted: 09:48pm 10 Jun 2021
Copy link to clipboard 
Print this post

I figured I had to be something like that. If I slow down to 1200 baud the pause has to go a lot longer.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 09:54pm 10 Jun 2021
Copy link to clipboard 
Print this post

use LOF to check for transmit complete
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9082
Posted: 12:43am 11 Jun 2021
Copy link to clipboard 
Print this post

Yes, I remember having that issue with serial ports when I was newer to the MM chips.
I used(and still use) LOC to check for something in the buffer, and you can use a simple DO/LOOP to wait till there IS something in the buffer - if that is all you are waiting on.  That idea would not work in code that needs to be doing other things too, cos it would halt the rest of the code while it waits only on the next message if you see what I am getting at.

DO:LOOP UNTIL LOC(#1)<>0 'Wait for something to arrive in the buffer
Pause 50 'Allow all of message to arrive in the buffer
...


My problem was I did not have the pause command, so I was waiting for data in the buffer, then trying to process it before it had a chance to arrive - the interpreter was too fast!  
Adding the pause fixed that issue when I was learning.

Or another way:

DO:LOOP UNTIL LOC(#1)>=10 'Wait till there is at least one message in the buffer
...


That will still 'Gotcha!' if there is LESS then ten bytes in the buffer and no new message arrives - it will sit there waiting again.  
That's why I pause, then read the buffer a byte at a time looking specifically for an 'End of message byte', which is unique and cannot be part of any message.  The buffer then becomes an automatic message queue for you in the background.  

BTW, with the PicoMite - are the serial port buffers fixed, or can they be defined as in the other MMBASIC series of chips?  Output buffer is fixed at 255 bytes in all the other chips I think, so just the input buffer is all I care about adjusting.  If the input buffer is going to be fixed in the PicoMite, I can still live with that.
Smoke makes things work. When the smoke gets out, it stops!
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 01:52am 11 Jun 2021
Copy link to clipboard 
Print this post

DS3231 RTC module now working on picomite.



This code sets the date and time. It is necessary to fill in the array hx() with the necessary values in hexadecimal Binary Coded Decimal (BCD) in the order shown in the comment on the first line.

 ' address,seconds,minutes,hours,dayofweek,day,month,year,control -- enter numbers in BCD as hex
 Dim integer hx(8)=(&h0,&h0,&h36,&h21,&h4,&h10,&h06,&h21,&h10) ' hx(0) is address to write to
 SetPin 14,i2c1sda
 SetPin 15,i2c1scl
 I2C1 open 100, 1000
 I2C1 WRITE &h68,0,9,hx()
 I2C1 close
 End

The following code gets the RTC values and sets date$ and time$:

dim integer d(9)
SetPin 14,i2c1sda:  SetPin 15,i2c1scl: I2C1 open 100, 1000
i2c1 WRITE &b1101000,1,1,0 ' set the read address to 0
i2c1 read &h68,0,7,d()
dt$=str$(bcd_bin(d(4)))+"-"+str$(bcd_bin(d(5)))+"-20"+str$(bcd_bin(d(6)))
tm$=str$(bcd_bin(d(2)))+":"+str$(bcd_bin(d(1)))+":"+str$(bcd_bin(d(0)))
date$=dt$:time$=tm$
?date$,time$
end

Function bcd_bin (Val as integer) as integer ' from FruitOfTheShed
 local integer tmp
 ' convert the BCD values to binary
 tmp = val AND &b00001111
 bcd_bin = (val AND &b11110000) * 10 / 16 + tmp
END Function

Because RTCs have been built into many micro/maximites for a long time, I had to do some digging and experimenting to get it right. I found code from 2011 for the DS1307 using line numbers and different I2C commands, and a matherp offering with a CSUB. The bcd_bin function is derived from a DS1307 sub in FruitOfTheShed.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
led-bloon

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 204
Posted: 02:22am 11 Jun 2021
Copy link to clipboard 
Print this post

Edit: As this was off-topic, moved to a separate topic
led  
Edited 2021-06-11 13:16 by led-bloon
Miss you George
 
     Page 13 of 17    
Print this page
© JAQ Software 2024