Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xmc1100 (xmc2go) Hardware Support #42

Merged
merged 2 commits into from
Dec 23, 2022

Conversation

devweblab
Copy link
Contributor

Hi Stefan
Cool project, Thank you for sharing.
I have it now running on the xmc2go from infineon:
https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_2go_xmc1100_v1/
https://github.com/Infineon/XMC-for-Arduino
For now Memory/Save is not working. Maybe it is possible to implement it in future with this:
https://github.com/Infineon/mtb-example-xmc-flash-eeprom
Feel free to include my changes from my branch (XMC1100_XMC2GO).
Thank you and regards
Florian

@slviajero
Copy link
Owner

slviajero commented Dec 23, 2022 via email

@slviajero slviajero merged commit 7cb4b80 into slviajero:main Dec 23, 2022
@slviajero
Copy link
Owner

I merged the two changes now in the master branch, but there are a few things I don't understand right now

MEMSIZE is set to 12k in the BASIC main file, but then again there is an autodetect of the memory later in hardware-arduino.h. Why is this done in the two places? The MEMSIZE directive will always override the autodetection. Does the autodetection not work?

delay(0) is disables in byield(). Is there a problem with delay(0) on this platform? Usually this can be very platform dependent. delay(0) on ESP is a true yield and needed on 8266. On AVR 8bit it is essentially nop. Is there anything special on the Infinineon platform?

pinMode is set to numerical values 0xc0UL, 0x80UL instead of INPUT/OUTPUT. I assume the macros INPUT and OUTPUT are not defined on the XMC?

@devweblab
Copy link
Contributor Author

Wow, thank you very much.

I have not looked deeper into the MEMSIZE Problem. It worked automatically with another version made from Release 1.31. Needs further inverstigation:
Prints "Stefan's Basic 1.4a Memory 129 0" instead of "Stefan's Basic 1.3 Memory 12000 0" when MEMSIZE not set.

Yes true, i think it is a problem with that platform. Unnfortuantely i cannot debug from arduino with jlink. But device hangs if delay is set to 0.

Maybe there is a better solution to do this. But PINM is not working with 0 and 1 (as defined in your code, not INPUT/OUTPUT i think), i had to use the numbers defined here https://github.com/Infineon/XMC-for-Arduino/blob/0dcbd5822cb59d12a7bdae776d307fae9c607ed7/cores/xmc_lib/XMCLib/inc/xmc1_gpio.h (XMC_GPIO_MODE_OUTPUT_PUSH_PULL and XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN)

(I also found out that the RND/TRND function is not working, dont know why for now.)

@slviajero
Copy link
Owner

slviajero commented Dec 23, 2022 via email

@devweblab
Copy link
Contributor Author

The memory detection works now. Thank you very much!
Stefan's Basic 1.4a Memory 10343 0

No, the PINM Function does not work anymore. The Device is hanging after calling it.

Here the output of the RND command. Or am I doing something wrong?

RND(100)
Syntax Error
TRND(100)
Syntax Error

With delay(0) the output after start is only:

S

I bought the board on mouser (cheapest i think?). I wrote them because the datasheet is wrong. It has only 32kB Flash instead of 64kB. So if you order one - there are differen Versions with 32 or 64 kB (see newer Datasheets)
(For FLOAT the 64kB Version would be needed.)
And no, the Seeduino XIAO is a SAMD21 (Atmel) and the XMC is a XMC1100 (Infineon) as far as i can remember. But cortex/arm, etc (I use the XIAO for cmsis and micropython) so you are correct, mostly identical. The infineon xmc-arduino is different/special i think.

Happy christmas

@slviajero
Copy link
Owner

slviajero commented Dec 23, 2022 via email

@slviajero
Copy link
Owner

slviajero commented Dec 23, 2022 via email

@devweblab
Copy link
Contributor Author

Yes, the memory detection is perfect.
Ok, now the RND does work, my fault, thanks for clarification.
And also the PINM works now!
Ok, yes you are correct, cortex-m0 and the xiao is cortex-m0+.
So i will try some examples now and have fun. Very cool! Thank you again.
Yes, hopefully a 64kB. I ordered the 64kB too and received the 32kB.

@devweblab
Copy link
Contributor Author

Found out why it is not working with delay(0).
setInterval() does set the interval of the task to 0:
https://github.com/Infineon/XMC-for-Arduino/blob/0dcbd5822cb59d12a7bdae776d307fae9c607ed7/cores/wiring_time.c#L229
startTask() does check if the interval is 0 and return -2 instead of starting the task.
https://github.com/Infineon/XMC-for-Arduino/blob/0dcbd5822cb59d12a7bdae776d307fae9c607ed7/cores/wiring_time.c#L505
So not sure if that is a bug or a feature ;)

@slviajero
Copy link
Owner

slviajero commented Dec 23, 2022 via email

@devweblab
Copy link
Contributor Author

Interesting, thanks for the explanation. Yes, such problems with porting/microcontroller can take a lot research and time.
This basic is really cool and good hardware abstraction layer. Now i can do something with the device.
Just for information - found that not all examples are working. For example DIM in animal.bas:
70: Args Error
I will test/play/investigate more.

@slviajero
Copy link
Owner

slviajero commented Dec 24, 2022 via email

@slviajero
Copy link
Owner

slviajero commented Dec 24, 2022 via email

@devweblab
Copy link
Contributor Author

Yeah, found out that. I forgot to change that after checkout the new version form github. Multidimensional is working fine.
Nice tip with the eeprom. I think i have a little i2c eeprom (256kbit), maybe i will try that. (But i would prefere saving to flash.)

I know basic from the C64/vice/frodo and some other interpreters. I ported the SAM (Simple Assembler and Monitor) for this project https://github.com/Schuemi/c64-go
With that you can manipulate/control/watch the cpu/emulator directly.

Is there a way to write to registers in tinybasic?
For example in https://github.com/billroy/bitlash there is a simple function to set AVR registers with inb() and outb(). (Like peek/poke on the Commodore 64 are)
numvar func_inb(void) { reqargs(1); return *(volatile byte *) arg1; }
numvar func_outb(void) { reqargs(2); *(volatile byte *) arg1 = (byte) arg2; return 0;}
As far as i see and read in the documentation you protected the program space and limit access with peek/poke to the memory only? So maybe better a seperate evil function for doing that?

@slviajero
Copy link
Owner

slviajero commented Dec 24, 2022 via email

@slviajero
Copy link
Owner

slviajero commented Dec 24, 2022 via email

@devweblab
Copy link
Contributor Author

Ah, super idea to use the eeprom like a drive/storage :) I also like the old simple/direct systems.
Very interesting the Locomotive BASIC, new for me.
Have to study everything you wrote and make some test, read documentation, etc
Thank you very much for the detailed explanation!

@devweblab
Copy link
Contributor Author

And with lego lines i learned to control simple things. See http://lukazi.blogspot.com/2014/07/lego-legos-first-programmable-product.html :) Running on the C64 and intel 286.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants