Swordfish

Structured BASIC for PICĀ® Microcontrollers
It is currently Tue Mar 19, 2019 6:16 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: K50 and USB issue
PostPosted: Mon May 15, 2017 1:39 pm 
Offline
Registered User
Registered User

Joined: Fri Jan 30, 2009 6:27 pm
Posts: 1087
Location: US
I've been using the 2x/4xK50 for some USB projects lately, and recently ran across an issue.

Once in a while the device would just stop responding to host requests (I was using CDC at the time).
Poking around I found that the K50 was sending a STALL response to the host DATA_IN packet (which typ indicates an error), and everything just stops.

Reading through the K50 datasheet there's a note that caught my eye:
Code:
The firmware should not set the UOWN bit in the same instruction cycles as any other
modifications to the BDnSTAT soft register. The UOWN bit should only be set
in a separate instruction cycle, only after all other bits in BDnSTAT (and
address/count registers) have been fully updated.
I haven't seen that note in previous datasheets, but it is in recent ones from new devices like the 16F1xxxx w/USB.

The SF USB code is based on an old version of the MLA stack and doesn't follow the note's recommendations.
Looking at newer versions of the stack C code I see they've changed it to meet the above (quite a while ago, actually).
I made that change and bingo, things started working like normal.

I don't know if this is something that only affects some devices, but the change is included for all of them...
maybe it's just not in the older datasheets.

Anyway, here's a modified USBSystem.bas file that incorporates the change. It's just knocked together, but it changes both HID and CDC to follow the recommendation above.


Attachments:
USBSystem_v144.zip [23.16 KiB]
Downloaded 72 times
Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Mon May 15, 2017 2:34 pm 
Offline
Swordfish Developer
User avatar

Joined: Tue Oct 03, 2006 7:01 pm
Posts: 1142
Location: Saltburn by the Sea, UK
Thanks for that Jerry, a really important piece of work. I use USB a lot - thanks for sharing...


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Mon May 15, 2017 2:40 pm 
Offline
Swordfish Developer
User avatar

Joined: Tue Oct 03, 2006 7:01 pm
Posts: 1142
Location: Saltburn by the Sea, UK
I've updated the wiki

http://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.USBLibrary


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Tue Jan 23, 2018 12:57 pm 
Offline

Joined: Tue Oct 03, 2006 8:54 pm
Posts: 241
After having to reinstall my pc a little while ago I am having some issues with various modules/files.


Where should I be copying the new usb modules to in the wiki?

Richard

_________________
Hmmm..


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Tue Jan 23, 2018 1:58 pm 
Offline
Registered User
Registered User

Joined: Fri Jan 30, 2009 6:27 pm
Posts: 1087
Location: US
You should be able to put them in your UserLibrary folder and they'll be available to all projects.

I think it appears under 'MyDocuments\Swordfish" but I don't remember (I have everything moved around).


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Tue Jan 23, 2018 2:16 pm 
Offline

Joined: Tue Oct 03, 2006 8:54 pm
Posts: 241
I wanted to make sure its using the new usb files. does swordfish use the user files in preference to the installed library files in program data\....usb files


(I have everything moved around). I'm intrigued where do you store them?

I would like to have all the pic includes, libs and user libs located else ware so I can easily check them into SVN.

I also recently had an issue after installing a fresh copy swordfish. The adc was locking up due to

#const _adc = $05 // 5 ADC channels available

with the 18F2553.bas file

it would be nice to have a way of keeping modified files in an easy to maintain way.
Richard

_________________
Hmmm..


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Tue Jan 23, 2018 5:55 pm 
Offline
Registered User
Registered User

Joined: Fri Jan 30, 2009 6:27 pm
Posts: 1087
Location: US
I don't care for the way win7 locates files all over the place and hides some of them... c:\programdata, users folders, roaming folders, etc.
I install everything in d:\swordfish, move the folders from C:, and create symbolic links back to the original locations.

I tend not to use the library folders. I put copies of everything into a project folder and use those. That way I have all the files I used to build a project and don't have to worry about things that might change.

Sometimes it's a pain doing it that way (esp. if you really want to update libraries), but I'd rather have all the originals I used.


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Wed Jan 24, 2018 9:07 am 
Offline

Joined: Tue Oct 03, 2006 8:54 pm
Posts: 241
I tried to do something like this but the shortcuts don't seem to do the trick. Are "symbolic links" different to shortcuts?

I just get "unable to open system file"
why did you install to d: instead of just for example "c:\swordfish\compiler\"?

Richard

_________________
Hmmm..


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Wed Jan 24, 2018 10:47 am 
Offline
Registered User
Registered User

Joined: Fri Jan 30, 2009 6:27 pm
Posts: 1087
Location: US
Quote:
why did you install to d: instead of just for example "c:\swordfish\compiler\"?
I have multiple partitions/drives setup for tools, projects (data files), etc.
I do it primarily to make it easier to backup/image different things without having to backup an entire drive.
It also allows me to move things between systems easier since I setup all my machines the same way.
Just something I started doing ages ago, and have stuck with it over the years.

Quote:
Are "symbolic links" different to shortcuts?
Yes, a junction point is different than a shortcut. Junction points are a type of link that can point to a folder,
and they're transparent to programs. Probably easiest to just google the details.

NOTE: do the following at your own risk. I'm not recommending this... just showing the steps involved.

You make a link to a directory using the 'mklink' command.
Let's say you wanted to move 'C:\ProgramData\Mecanique\Swordfish' to another location, say 'D:\Programs\Swordfish'
- move all contents from 'C:\ProgramData\Mecanique\Swordfish', copying them to 'D:\Programs\Swordfish'
- delete the original folder and its contents 'C:\ProgramData\Mecanique\Swordfish'
- make a symbolic link to the new location. open a command prompt and type:
mklink /D "C:\ProgramData\Mecanique\Swordfish" "D:\Programs\Swordfish"

There are also programs to help with some of this like Junction Link Magic (http://www.rekenwonder.com/linkmagic.htm)
but you still have to move the folders yourself.


Top
 Profile  
Reply with quote  
 Post subject: Re: K50 and USB issue
PostPosted: Wed Jan 24, 2018 11:41 am 
Offline

Joined: Tue Oct 03, 2006 8:54 pm
Posts: 241
Thanks for the reply Jerry, I spoke to a colleague and googled it and have sorted this out now and done something very similar.
so I did the following which means I have a single directory now that I can check into SVN tortiose
Quote:
Swordfish was installed into C:\swordfish\compiler

the C:\ProgramData\Mecanique\Swordfish was copied to C:\Swordfish\data
the C:\ProgramData\Mecanique\Swordfish folder was deleted then the following command was run in a "administrator" dos shell

C:\>mklink /J C:\ProgramData\Mecanique\Swordfish C:\Swordfish\Data

this makes a symbolic link and allows svn to check in the data but also allows the compiler to think the files are in the correct place.

do the same with the user directory

the C:\Users\richard.benfield\Documents\Swordfish C:\Swordfish\Users
the C:\Users\richard.benfield\Documents\Swordfish was deleted then the following command was run in a "administrator" dos shell

C:\>mklink /J C:\Users\richard.benfield\Documents\Swordfish C:\Swordfish\Users



Thanks again Jerry, always so fast to give a good reply.

_________________
Hmmm..


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group