Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Com4, what am i doing wrong??

 
Post new topic   Reply to topic    Forum Index -> ZX-1281
Author Message
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 14 June 2010, 22:02 PM    Post subject: Com4, what am i doing wrong?? Reply with quote

Hi

I am trying to read an RFID chip on com4 on a zx128ne

I have tested the output of the rfid chip on my logic analyser, and all is good with correct data coming out. 9600baud TTL inverted

here is the datasheet
http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf

However I cant get the zx to read it with com4, this is the code i have...

Code:

PUBLIC com3TXQueue(1 to 32) as Byte
PUBLIC com4RXQueue(1 to 100) as Byte

PUBLIC CONST com3tx_pn as Byte = 15
PUBLIC CONST com4rx_pn as Byte = 14



Sub Main()
        'setup software coms
   Call ComChannels(2, 9600)
   
   'OPEN COM3 - for lcd
   Call OpenQueue(com3TXQueue, SizeOf(com3TXQueue))
   Call DefineCom(3, 0, com3tx_pn, &H08)
   Call OpenCom(3, 9600, 0, com3TXQueue)
   
   'OPEN COM4 - for rfid
   Call OpenQueue(com4RXQueue, SizeOf(com4RXQueue))
   Call DefineCom(4, com4rx_pn, 0, &H80)
   Call OpenCom(4, 9600, com4RXQueue, 0)


Do
   if GetQueueCount(com4RXQueue) > 0 then
              Debug.print  GetQueueStr(com4RXQueue)
        end if
        Call Sleep(0.1)
Loop



What am i missing?

Cheers

Ben
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 14 June 2010, 22:08 PM    Post subject: Re: Com4, what am i doing wrong?? Reply with quote

sturgessb wrote:
What am i missing?
Perhaps this post about inverted mode problems.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 14 June 2010, 22:22 PM    Post subject: Reply with quote

Thanks Don

But I have uninstalled the IDE and installed latest 3.0.2 version, and getting the same problem Sad

Ben
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 14 June 2010, 22:39 PM    Post subject: Reply with quote

sturgessb wrote:
But I have uninstalled the IDE and installed latest 3.0.2 version, and getting the same problem.
If you do only that, you will indeed continue to have the same problem. Note that the correction for the inverted mode problem is present only in the ZX Library v3.0.5 and later. The ZX Library that gets installed with the current installer is v3.0.4. We didn't update the installer because we thought that we would have a new release sooner than we've been able to.

The special ZX Library update is the fifth entry on the Downloads Page. Just download the .zip file and extract the files to the zxlib subdirectory of the ZBasic installation directory.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 14 June 2010, 22:45 PM    Post subject: Reply with quote

Sorry Don.

But still, with 3.0.5, same problem Sad

perhaps the bug still exists for 128?
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 14 June 2010, 23:39 PM    Post subject: Reply with quote

sturgessb wrote:
perhaps the bug still exists for 128?
It is remotely possible but not likely, I think. Does a re-compiled application sign on with v3.0.5 or v3.0.4?
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 14 June 2010, 23:53 PM    Post subject: Reply with quote

3.0.5

for sanity sake (to check i didnt have a bad pin etc) i changed the opencom to be non-inverted. So you know, this works, so its definitely the problem.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 15 June 2010, 1:57 AM    Post subject: Reply with quote

sturgessb wrote:
So you know, this works, so its definitely the problem.
Thanks for devising this test.
I rebuilt the ZX Library and verified that the updated SW UART code was re-compiled for the ZX-128ne (and all other devices as well). I posted this as v3.0.6 just to avoid any confusion. Download that, extract it to the ZBasic/zxlib subdirectory and see if that rectifies the problem.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 15 June 2010, 10:01 AM    Post subject: Reply with quote

thanks Don, will test this tonight.

Cheers

Ben
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 15 June 2010, 17:30 PM    Post subject: Reply with quote

sorry Don, still no joy with 3.0.6

Call DefineCom(4, com4rx_pn, 0, &H08) works

Call DefineCom(4, com4rx_pn, 0, &H80) does not
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 15 June 2010, 20:42 PM    Post subject: Reply with quote

sturgessb wrote:
Call DefineCom(4, com4rx_pn, 0, &H80) does not
If that's actually the value you're using for the fourth parameter then that is the problem - it should be &H88 for inverted, 8-bit. The only two legal values for the least significant four bits are 7 and 8; all other values result in silent failure.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 15 June 2010, 20:52 PM    Post subject: Reply with quote

Arghhh and I though I was getting better at this stuff!

The zx system library reference manual says &H80 for inverted, i thought 8 bit was standard and therefore didnt need to be specified.

Crap, im sorry for wasting your time Don
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 15 June 2010, 21:29 PM    Post subject: Reply with quote

sturgessb wrote:
i thought 8 bit was standard and therefore didnt need to be specified.
Just to be clear, the "Serial Channel Configuration Flag Values" table in the description of DefineCom() describes several fields which can be combined to get the desired effect. The value &H08 means "non-inverted, no parity, 8-bit" while the value &H88 mean "inverted, no parity, 8-bit".

This same concept is used in the description of bit fields for several ZBasic System Library routines including DefineX10(), ShiftInEx(), ShiftOutEx(), etc.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 15 June 2010, 22:02 PM    Post subject: Reply with quote

I should have known that, school boy error. Its a bugger we didnt spot that error in my code in first post.

When i change it to &H88 i just get giberish so i have no bloody idea whats going on, the spec sheet for the rfid must be wrong as i get a correct value when set to non-inverted

However, it doesnt matter, the value is the same everytime, and thats whats important, so I dont want to waste any more of your time.

Ben
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZX-1281 Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group