Hardware SPI hangs on ZX-24x

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
coopecb1
Posts: 8
Joined: 18 May 2011, 11:30 AM

Hardware SPI hangs on ZX-24x

Post by coopecb1 »

Using software SPI works fine:

Code: Select all

Option TargetDevice ZX24x 
Sub Main()
Dim odata(1 to 2) as Byte
Dim idata(1 to 2) as Byte
Dim SPIMode as Integer
SPIMode = 16
Call DefineSPI(9,10,11)
Call OpenSPI(1,SPIMode,12)
do
odata(1) = &HA5
odata(2) = &H77
Debug.Print "Got to here 1"
Call SPICmd(1,2,odata,0,idata)
Debug.Print "Got to here 2"
Call Sleep(0.1)
loop
End Sub
The following hangs at SPICmd. CS goes low once and stays there:

Code: Select all

Option TargetDevice ZX24x 
Sub Main()
Dim odata(1 to 2) as Byte
Dim idata(1 to 2) as Byte
Dim SPIMode as Integer
SPIMode = 0
Call OpenSPI(1,SPIMode,12)
do
odata(1) = &HA5
odata(2) = &H77
Debug.Print "Got to here 1"
Call SPICmd(1,2,odata,0,idata)
Debug.Print "Got to here 2"
Call Sleep(0.1)
loop
End Sub
This is using ZBasic with the patch you sent me (3.3.1) that has the ADC fix for the 24x.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Hardware SPI hangs on ZX-24x

Post by dkinzer »

coopecb1 wrote:The following hangs at SPICmd. CS goes low once and stays there:
The source of the problem has been found and corrected; it only affects xmega-based ZX devices. You can download an updated partial set of ZBasic Library files via the link below. The contents of the downloaded archive should be extracted (preserving path prefixes) to the zlib subdirectory of the ZBasic installation directory. When you're finished you should find two files with today's date in the zlib\avr\lib subdirectory. Re-compiling your code should then produce the correct result.

http://www.zbasic.net/download/zlib/3.3 ... _xmega.zip
- Don Kinzer
coopecb1
Posts: 8
Joined: 18 May 2011, 11:30 AM

Post by coopecb1 »

Once again, thanks for getting to this so quickly, and on a holiday weekend at that!

I have to wonder, am I the first user of the 24x? At least for these functions?
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

coopecb1 wrote:I have to wonder, am I the first user of the 24x?
Of course, not everyone uses the same set of System Library routines. As much as we try to test thoroughly, we don't test every possible program so problems are bound to arise. We don't promise to deliver perfect code (no one can, of course). We do, however, endeavor to correct problems that do arise as quickly as possible.
- Don Kinzer
Post Reply