Are we writing Modules the correct way?

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Are we writing Modules the correct way?

Post by octal » Thu Feb 01, 2007 9:35 pm

:shock:
Hi,
I have some interrogations about the way modules are written. Are we writing them the correct way? Or am I missing something in the syntax of SWFBasic?

Software modules that emulates hardware ones like SUSART, SI2C, and so on are writen so that they behaves like Hardware ones USART/I2C/...

Is this truely a good thing?
For Hobbists, perhaps it is because it let them use PICs without USART for example to send data in RS232 format. Idem for I2C. This is fine.

Software versions are also MORE FRIENDLY because they let users CHOOSE the Pins to use for such functionnalities. This is also a very nice advantage,
BUT I think that this is the problem: Software version have more flexibility, BUT they are very limited because they are written to work (emulate) like hardware ones.
One kind of limitation we can find is, for example, the fact that, SOFTWARE USART let me choose the pins for TX/RX but the way it's written it let me choose ONLY ONE Soft-USART. Why ? The PBP way of managin Software routines (for I2C for example) is much more flexible...

it would be nice if Software Module were written i such a way that they let users create multiples instances of the Same Software-Driver.

The only Module that do that NICELY is Timer Module. I have reworked SUSART to create a Mutli-SUSART module that let me create up to 16 modules ... (I agree that 2 are sufficient).
It would be nice to have perhaps two versions of modules, one with a single instance and another with multiple instances ...
may be I'm wrong !!! may be I missunderstood something in the doc of SWFBasic... please correct me if so. If it's not the case, it would be nice if David give us a template or at least some guidelines on how to uses (perhaps) preprocessor directives to have the same fonctionnalities in the same module without very high cost in code size !

PS. For the history, I needed two I2C buses on a PIC, one for reading an I2C memory so I used a SOFT-I2C one, and one for communicating with a sensor. I needed again for 3 other I2C buses to communicate with two digital counters and a weighting machine, and all the I2C peripherals and mesure tools are set to Adress 000 Hardwired without any Jumpers to change the address. The costumer gave us no authorisation to touch or reconfigure the mesure tools, and the electronic circuit was an old card. So no way to rework anything other than software. I tried yesturday to rework the SI2C module to have multiple-SI2C Software-controllers on the same PIC, using SWordFish ... and it's working very very fine :lol: The costumer was so satisfied that he is planning to buy 3 licences of SWFBasic for his dev team. My boss was very happy because he had received today a check of 4.500 euro for the very Quickly and WELL DONE and work ... and for the high quality tool we showed to the costumer... and I had a very good satisfaction because I had put SWFBasic in a truely industrial environment... and for bonus I had on my salary...a bonus of about 30 euro ... (yes I have not forgotten a zero ... :( ) ... And for the decision I have made ... to quit my actual JOB !!!

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Fri Feb 02, 2007 3:44 pm

The software USART allows you to assign TX and RX at runtime, so it's as flexible as PBP.

As I2C devices tend to share a bus, the pins are fixed at compile time. Direct addressing, rather than runtime indirect addressing, produces much smaller code and is much faster. You will see this approach in other compilers, such as Microchips C18 compiler.

When comparing Swordfish to other BASIC languages, it is important to note that all of the modules provides are written in the Swordfish language itself, like C18 or CCS C. No ASM or binary modules are used.

This means that you can modify a particular module to suit your needs. For example, by examining the shift library a possible solution presents itself in that the software I2C library could be modified to work with indirect addressing. In other words, you can configure at runtime rather than at compile time.

Post Reply