MemoryAccess module added to the Wiki

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

MemoryAccess module added to the Wiki

Post by TimB » Sat Aug 04, 2007 5:14 pm

Add a module for reading and writing to Program Memory

http://www.sfcompiler.co.uk/wiki/pmwiki ... moryAccess

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Sun Aug 05, 2007 7:23 am

Many thanks Tim - it looks like a useful library. I've not tried writing to program memory before, but I might give it a go now. Next step, a bootloader written in Basic!

Regards,

Steve

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

Post by octal » Sun Aug 05, 2007 7:34 am

Hi Tim.
Nice Work. I'll manage a little time to test it.
Hi Steven,
Writing a bootloader is not as easy as it seems (actually impossible with Swordfish Basic without acrobaties). The problem is not in writing in code space of pic mcu, the problem is to be able to store a PROGRAM at a SPECIFIC position in Code Space. Until now, Swordfish does not allow to put a specific code at a certain ABSOLUTE address in code space. David stated that he (perhaps) will manage to add a ORG-ing possibility. This will let us to put at the start of the code a jump to the user program or to the bootloader code.

Regards
Octal

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sun Aug 05, 2007 9:55 am

Thanks

I have a neat SMS type text entry program utilising constant arrays, but by using MemoryAccess.read instead I saved a whole heap of code, its an interesting example of how some thought when writing code has a big effect.

I'm also working on a corker of a set of modules that lets you add interrupts routines together. Very very simple to use and very modular.

I will start with the classic 7Seg Led clock and from a users point of view it could not be simpler.

BTW Octal I have that Enj code. It's written very tightly but is not very modular, do you want to have a look?

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

Post by octal » Sun Aug 05, 2007 9:57 am

Hi Tim,
I would be very glad to have the code. May be I'll rework it to make it more modular. Can you send it to my email please?

Regards
Octal

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sun Aug 05, 2007 10:02 am

Some thing else

I was talking to Dave about how I tried to read floats using readlongword and found it was not working, it turns out SF knew more about what was going on than me and was doing doing typecast conversions.

The work around obviously was to write a float version (below) but another trick was to force a type cast

Example... If I wrote

myfloatvar = ReadLongWord(@myarray4)

Then as myfloat is a float it gets typecast from a longword as the function deals with longword but by adding .aslongword the casting is forced to prevent the conversion

myfloatvar.aslongword = ReadLongWord(@myarray4)

Here is the other way using another function

// read a Float from ROM
Public Function ReadLongWord (pAddress As TABLEPTR) As Float
EECON1 = 0
EEPGD = 1
TableRead
result.Byte0 = TABLAT
TableRead
result.Byte1 = TABLAT
TableRead
result.Byte2 = TABLAT
TableRead
result.Byte3 = TABLAT
End Function

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sun Aug 05, 2007 10:07 am

It's sent

Actually it is modular I was looking at the wrong file :oops: . It's written by Gabi who always surprises my with the great code he produces.

Post Reply