• AVR Freaks

Hot!Minibasic for Pic32

Page: < 12345.. > >> Showing page 3 of 11
Author
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 01:42:12 (permalink)
0
ORIGINAL: mimemike

Hi Dario, Hope you had a good nights sleep..... while you were sleeping I have managed to do teh following....


Good Mike!


1. malloc - Is in stdlib.h


Nice news! A pity that it was not even talked about into the Docs... I did search for it ... [:@]wink


2. Did a bit of work and now it compiles (with lots of warnings) for the PIC32
  Needs io/uart/interrupts etc to be completed - currently only for PIC18
  With Demo compiler - need optimization level 5 for C32 and Linker
  Also Set to 16bit mode for compiler and linker
  Compiled size FLASH 10900Words (~42KBytes)       SRAM ~6.7KBytes


Ok, not bad then, about increase in code size, some 4:3 ratio.


Current ZIP will eventually be placed at:

http://www.pic32.org/minibasic/MiniBasic32.zip



I go getting them.

GENOVA :D :D ! GODO
#41
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 01:43:35 (permalink)
0
ORIGINAL: mimemike
Did chunks of cpu.c, io.c and some iohw.c
Still need a good amount of work in those files - especially iohw.c


I'll try to take a look - of course I don't know much of those PICs, but we'll learn from this!

GENOVA :D :D ! GODO
#42
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 02:19:42 (permalink)
0
ORIGINAL: DarioG
I'll try to take a look - of course I don't know much of those PICs, but we'll learn from this!


All new for me as well wink

Good way to learn them though.

Look for the comments  like //######### FIX THIS ##########
Made to stand out using ###
Some areas I just filled in values so it would compile - didnt have time to go into the details.

The pdf's in ....Microchip/PIC32/docs/ are very useful.

Only found the malloc by doing a file search since when I compiled the code it did not complain about it!

Mike



Mike
#43
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 02:26:29 (permalink)
0
I'm compiling it now and more or less it goes.

If you don't mind, I'll copy your C code to C18 and adjust it to make it compile again - I'd like to keep the source cross-platform.
So I'll send you a new one in the early afternoon, if you can wait for it without touching your copy.

Thanks

GENOVA :D :D ! GODO
#44
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 02:51:59 (permalink)
0
I can wait till my morning - it's my turn to go to bed this time.... after I put the trash and recycling out.

P.S. Should still compile for the PIC18 - just made the "includes.h" to sort alot of it out.

Mike
#45
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 03:03:04 (permalink)
0
Good night then Smile

Looks like the time Zone drove mad my Windows 98... some of your files come from the future... !

I readapted most of files to C18 , and retuned them to C32 as well.
C18 compiles ok, C32 compiles ok apart from those "TRISA" in iohw.c ... funny then, how did they call the TRIS registers?? SmileSmile

You can find both updated versions at my site.
Please check date against yours - looks like in some cases you got an older version of minibasic.c , not sure how it happened.

GENOVA :D :D ! GODO
#46
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 03:18:52 (permalink)
0
I am in your future - its aprox 11:15pm - Thursday 6th December here, you are probably just starting to think about lunchgrin

I saw something in one of the compiler documents about I/O ports (The perpheral Lib I think)

Will give it a go wen I get to te office tmorrow.

Mike
#47
jarin
Super Member
  • Total Posts : 848
  • Reward points : 0
  • Joined: 2005/05/23 13:50:02
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 03:38:40 (permalink)
0
<non technical comment>

Gentlemans, I'm watching your progress and I'm very happy for what you're doing, this MiniBasic looks great.

I also noted this extremly effective two-phase developement. While one guy in Europe sleeps, second one in New Zealand is working and vice versa! wink

</non technical commend>

Jaromir Sukuba, Bratislava, Slovakia
http://jaromir.xf.cz/  - open source PIC18 debugger.
#48
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 05:17:25 (permalink)
0
We've just been lucky - living down under of each other's ! Smile

Thank you Jarin - if you happen, take a look at the code and/or try it and review its keywords.

I'm thinking of one thing that would be nice, running Basic code straight out of a I2C/SPI EEprom, or a SDcard... it might be useful.

GENOVA :D :D ! GODO
#49
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 08:37:12 (permalink)
0
Added TIMER() function;
revised most of peripheral for PIC32 - something to get started with at least
taken a look at PIC32 interrupts (not used in this Basic, but you never know);
completed support for UART1 as I/O stream.

MiniBasic32 now compiles, just some Linker errors are there :


C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: address 0x9d03329c of MiniBasic32.elf section .text is not within region kseg0_program_mem
C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: section .rodata [9d000000 -> 9d00175f] overlaps section .text [9d000000 -> 9d03329b]
C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: section .eh_frame [9d001760 -> 9d0017cf] overlaps section .text [9d000000 -> 9d03329b]
C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: section .data [9d0017d0 -> 9d00191b] overlaps section .text [9d000000 -> 9d03329b]
C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: section .sdata [9d00191c -> 9d00191f] overlaps section .text [9d000000 -> 9d03329b]
C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: MiniBasic32.elf: section .text lma 0x9d000000 overlaps previous sections
C:\Programmi\Microchip\MPLAB C32\bin\..\lib\gcc\pic32mx\3.4.4\..\..\..\..\pic32mx\bin\ld.exe: MiniBasic32.elf: section .eh_frame lma 0x9d001760 overlaps previous sections
minibasic.o: I



Can someone (Zardoz) explain "what" do they mean? I can see no Linker or GLD file in PIC32 examples by Microchip... how do Segments and all the rest, in C32?

Thank you.

PS files updated:
http://adpm.homeip.net/files/MiniBasic.zip
http://adpm.homeip.net/files/MiniBasic32.zip




GENOVA :D :D ! GODO
#50
JasonK
Super Member
  • Total Posts : 3406
  • Reward points : 0
  • Joined: 2003/11/14 09:49:40
  • Location: Microchip Technology in Arizona, USA
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 10:08:41 (permalink)
0
That usually means that you're running out of space on the device. Are you using the 64KB-limited version of the compiler? You might try optimizing for size if you haven't already.

Jason Kajita
 Follow me on Twitter
http://support.microchip.com for urgent questions
#51
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 10:32:14 (permalink)
0
Hmmm, I actually picked a "128" device randomly, since by now this is just a proof of concept.
Now I've chosen a 512 one, and still I get the same errors.

Yes, I'm using the free compiler.

I activated O2 optimization now, and nothing changes.

Thank you Jason.

GENOVA :D :D ! GODO
#52
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 12:45:42 (permalink)
0
PIC32 Compiler Options:   -g -mips16 -Os

PIC32 Linker options : -Map="$(BINDIR_)$(TARGETBASE).map" -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)" -Os -mips16



need to use the -mips16 to get it small enough for the 64K limit.

Definately not as efficient as the PIC18 for code space.
Might to a quick trial with a PIC24 (which uses GCC also) to see if it is a compiler difference or a Processor difference.

Mike

#53
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 16:20:24 (permalink)
0
Thank you Mike.

Not sure if you're already working on the code, but anyway I just found out a couple of things that need to be "improved", in both C18 and C32 code.
The only file modified is minibasic.c - I've uploaded it.

I added some support for peripherals, you'll see it in the other files (you can see them included in the project).

As for compiling for PIC32, I've done as suggested by you and Jason, and this are my comments (I wrote to Jason as well):
I guess there's been significant additions to the code since his post
indicating that the size was 42KB?

Yeah, the Project you downloaded today was including the Libraries - corrected and added by myself today. This explains the increase in code.

Unfortunately, the Interrupt Handler that I added to day - just as a test, I grabbed it from a C32 example, says "it can't compile on mips16" ....

Can you also tell me how to make the char "signed" by default? Otherwise some code in the libraries fails because the tests are done on simple chars...


PS: for some reason, the new "CopyrightString" moved to #define... no longer gets printed on the USART [:@]

GENOVA :D :D ! GODO
#54
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 17:27:15 (permalink)
0
Unfortunately, the Interrupt Handler that I added to day - just as a test, I grabbed it from a C32 example, says "it can't compile on mips16" ....


See my post at: http://forum.microchip.com/tm.aspx?m=296546
void __ISR(_TIMER_2_VECTOR, ipl3) __attribute__((nomips16)) _T2Interrupt(void)
need to add the __attribute__((nomips16)) to all interrupts

PS: for some reason, the new "CopyrightString" moved to #define... no longer gets printed on the USART

I'll look into it - it should have been fine (Method works in a lot of other projects I have done)

Been to busy so far today, will download it soon.

Mike
#55
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 18:02:10 (permalink)
0
Unfortunately, the Interrupt Handler that I added to day - just as a test, I grabbed it from a C32 example, says "it can't compile on mips16" ....


added the __attribute__((nomips16)) and it compiles now.

Mike
post edited by mimemike - 2007/12/06 18:03:57
#56
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 18:34:16 (permalink)
0
DarioG
I'm thinking of one thing that would be nice, running Basic code straight out of a I2C/SPI EEprom, or a SDcard... it might be useful.

Should be possible to "SAVE" and RUN from  the on-board FLASH.

The Library reference manual "32-bit-Peripheral-Library-Guide.pdf" has a section on NVM Functions.
Specifically for writing to FLASH.

If we can keep the BASIC Interpreter under 64KBytes that gives us up to 448KBytes for BASIC Code storage. - Thats a good sized BASIC program... better than what the PICAXE and BASICSTAMP currently offer.

May need to write a simple bootloader to reside in kernel space if cannot fit it into the basic interpreter.

Mike





#57
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 18:38:04 (permalink)
0
Can you also tell me how to make the char "signed" by default?


Compiler MPLAB-C32-Users-Guide.pdf page 18 states:

-fsigned-char    Let the type char be signed, like signed char. (This is the default)

It is not the default!!

Adding it to the compiler line gets rid of the associated warnings..... only 2 warnings left after the compile now...


minibasic.c: In function `factor':
minibasic.c:1920: warning: passing arg 2 of `strtod' from incompatible pointer type
minibasic.c: In function `getvalue':
minibasic.c:3344: warning: passing arg 2 of `strtod' from incompatible pointer type


Mike
#58
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/06 19:06:51 (permalink)
0
Dario,
Will not be able to do any more until Tuesday next week (Moving House).
The changes I have mentioned are easy for you to do at your end so havent made a file up.


Mike
#59
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/07 02:03:06 (permalink)
0
Ok Mike, thank you very much.
I've worked on the issues and:
  • fixed the "strtod" Warning - it's okay now.
  • fixed the "unsigned char" one - shall we open a ticket? Maybe Jason will be after it Smile
  • fixed the mips16 thing in the interrupt, and also added the skeleton code from that other post of yours (I actually had not seen it) for future reference.
  • still have to realize that Copyright string thing, but anyway it's probably a C18 thing, maybe a rom/ram issue.
I'll upload the code to both my site and maybe pic32.org as well, renaming the older, just in case.
(I also emailed Dan, some days ago, telling him about our work, but got no reply so far...)

Well, I still CAN'T LINK! Same error as always, even with "-g -Os -fsigned-char -mips16" C Build options [:@] Shall I choose any particular MPU?

GENOVA :D :D ! GODO
#60
Page: < 12345.. > >> Showing page 3 of 11
Jump to:
© 2020 APG vNext Commercial Version 4.5