Page 1 of 1

disorganized native mode questions

Posted: 12 March 2008, 11:09 AM
by dlh
I've read through this forum and the recommended sections of the docs but I'm still unclear on a few things - possibly because they are over my head.

1. Is SPICmd the only way to handle extenal SPI EEPROM? With the ZX-40a, I'm using the ST M95512 (for which there are now three major suppliers with no minimum order). Being able to free all 64KB for user data is attractive for my application. Given the reduced life of flash, I would think that there would be limited use for PutProgMen/GetProgMem on the native mode devices. Is there any possibility PutProgMen/GetProgMem can be used with external EEPROM?

2. Is it possible to create linkable .obj files using ZBasic? I want to make my application open source (including Windows, Linux & Mac interfaces) but there are a couple of devices it supports where I'm restrained by a very restrictive NDA. I'd like to be able to hide this code while making the rest open, still allowing users to modify the ZBasic source for the open part if desired, which. I assume, would require distributing the .obj file for the restricted code. It would be handy for those of us who aren't fluent in C if we could do this in ZBasic.

3. There's a lot of C code to do things like USB and TCP/IP on AVR chips. Will we be able to make use of some of this?

Re: disorganized native mode questions

Posted: 12 March 2008, 13:28 PM
by dkinzer
dlh wrote:1. Is SPICmd the only way to handle extenal SPI EEPROM?
Yes. An external SPI EEPROM is no different than any other external SPI device.
dlh wrote:Is there any possibility PutProgMem/GetProgMem can be used with external EEPROM?
Inasmuch as the external EEPROM isn't Program Memory, this would seem to be inappropriate. A better course would be to create similar routines specifically for external SPI EEPROM which would likely utilize SPICmd() for device communication but they could also interact directly with the SPI control/data registers.
dlh wrote:2. Is it possible to create linkable .obj files using ZBasic?
There is no way to instruct the ZBasic compiler to do so. That said, it can be done by someone that understands avr-gcc and the significance of the ZBasic --keep-files options. It would probably make more sense, by the way, to distribute an object library. This is on the topic list for native mode application notes.
dlh wrote:3. There's a lot of C code to do things like USB and TCP/IP on AVR chips. Will we be able to make use of some of this?
Yes. You can specify C and assembly language source code files (.c and .S) as part of your project. The ZBasic compiler doesn't process these files directly but does add their names to the makefile that gets generated to perform the backend build. Similarly, object files and object libraries (.o and .a files) can be part of a project and are likewise added to the makefile.

Re: disorganized native mode questions

Posted: 12 March 2008, 14:34 PM
by dkinzer
dlh wrote:I'm using the ST M95512 (for which there are now three major suppliers with no minimum order).
What are the three suppliers? I see that Nu Horizons has the SO8 package for $1.64 in 1-99 quantities, slightly less for the TSSOP-8 package.

Posted: 12 March 2008, 17:07 PM
by dlh
I use the SO-8 so that's the one I was looking for. Arrow, Avnet, Future Electronics and Nu Horizons stock it. I don't think many of them stock the smaller one. See...

Posted: 12 March 2008, 17:31 PM
by dkinzer
dlh wrote:I don't think many of them stock the smaller one.
Actually, Nu Horizons has 8,000 of the TSSOP device (M95512-WDW6TP) in stock but only 570 of the SO8 device.

Re: disorganized native mode questions

Posted: 12 March 2008, 17:37 PM
by dkinzer
dkinzer wrote:create similar routines specifically for external SPI EEPROM.
I posted a set of such routines that will work for either native mode or VM devices. See http://www.zbasic.net/forum/post-4894.html#4894

Posted: 13 March 2008, 4:05 AM
by dlh
I've always used PutEEPROM/GetEEPROM going back to the BX-24. Can you provide a speed comparison between those routines and your SPICmd based routines for VM devices and compare the older routines on a VM device with the SPICmd routines on a native device?

BTW, thanks for the routines. I'm sure many will find them helpful.

Posted: 13 March 2008, 9:54 AM
by dkinzer
dlh wrote:Can you provide a speed comparison.
Using the test code below, writing 100 bytes of data took 5.8mS on a ZX-24a and 4.5mS on a ZX-24n. In contrast, the same test using the SPI EEPROM routines to write to an off-board AT25256A on the ZX-24a took 5.2mS.

Code: Select all

Const chan as Byte = 1
Const addr as UnsignedInteger = 10000

' uncomment this to use the SPI EEPROM routines
#define USE_SPI_EEPROM

#if Option.TargetCode = "Native"
Const pin as Byte = B.4
#else
Const pin as Byte = 5
#endif

Sub Main()
  Dim i as Integer
  Dim tick as Long
#ifdef USE_SPI_EEPROM
  Call InitSPI_EEPROM(chan, pin)
#endif
  tick = Register.RTCTick
  For i = 1 to 100
#ifdef USE_SPI_EEPROM
    Call WriteSPI_EEPROM(chan, addr, tick.DataAddress, 100)
#else
    Call PutProgMem(CLng(addr), tick, 100)
#endif
  Next i
  tick = Register.RTCTick - tick
  Debug.Print "Elapsed time is "; CStr(tick); " ticks."
End Sub