PIC18F14K50 and USB

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
richardb
Posts: 307
Joined: Tue Oct 03, 2006 8:54 pm

PIC18F14K50 and USB

Post by richardb » Tue Jul 14, 2009 1:02 pm

Is the PIC18F14K50 supported on swordfish? I'm specificly interested in USB support
Hmmm..

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

Post by Steven » Tue Jul 14, 2009 3:29 pm

Have a look here on the wiki: http://www.sfcompiler.co.uk/wiki/pmwiki ... ionHistory. The PIC18F14K50 is included in the download.

richardb
Posts: 307
Joined: Tue Oct 03, 2006 8:54 pm

Post by richardb » Tue Jul 14, 2009 3:56 pm

Thanks Steven,

I guess i'll just have to request one from microchip and have a go with it :)
Hmmm..

RDHeiliger
Registered User
Registered User
Posts: 26
Joined: Sun Oct 12, 2008 11:21 pm
Location: Utah

Post by RDHeiliger » Mon Aug 10, 2009 3:22 pm

I have had a couple of 14K50's for awhile, finally came up with a project. I am getting assembler errors (Illeagle Opcode). The program assembles fine when i use a 46K20 as the chip, I get the errors when i use the 13K50 or 14K50. This is a bit of the listing file where the errors start. Any thoughts on why i get these errors.

Code: Select all

  00000022            00936 M3_U01 EQU 34
  00000023            00937 M4_U16 EQU 35
  00000024            00938 M4_U16H EQU 36
0000                  00939         ORG 0X00
Error[122]  : Illegal opcode (SBCDSTD)
0000                  00940         GOTO SBCDSTD
0008                  00941         ORG 0X08
0008                  00942 SBDLYMS
Error[108]  : Illegal character (5)
0008                  00943         CLRF 5,0
0008                  00944 SBDLYMS16
Error[108]  : Illegal character (4)
0008                  00945         MOVWF 4,0
Error[108]  : Illegal character (2)
0008                  00946         MOVLW 255
Error[108]  : Illegal character (4)
0008                  00947         ADDWF 4,1,0
RD

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

Post by octal » Tue Aug 11, 2009 5:54 am

I dont think that USB support is implemented for the 18F14K50. Microchip has changed deeply their USB stack (firmware) to support the 18FxxKxx series (and PIC24xx), and at my knowledge, SF implements only firt version of Microchip firmware.

You may need to check the diff between first(v2) and second (v3) version of USB firmware from Microchip.

Regards

RDHeiliger
Registered User
Registered User
Posts: 26
Joined: Sun Oct 12, 2008 11:21 pm
Location: Utah

Post by RDHeiliger » Tue Aug 11, 2009 3:29 pm

Not sure if you are replying to me or to the first gentleman. The program i am trying only has the USART, and Analog modules in it, no USB. It simply reads analog inputs and sends them out serially.

Here is the code.

Code: Select all

Device = 18F14K50
Clock = 16
Config
   FOSC = IRC
 

// uses USART and AD libraries...
Include "USART.BAS"
Include "ADC.bas"
Include "convert.bas"

// variables
Dim ADMvolts(4) As Word          'read counts x RefCntPerMvolt
Dim PumpOn As Boolean               'toggles above and below 6 volts on AN1
Dim CalVolts As Word

//aliases
Dim Analog1 As PORTB.4
Dim Analog2 As PORTC.2
Dim Analog3 As PORTC.1
Dim Analog4 As PORTC.0
Dim DigOut As PORTB.6               'digital output for aux funtion (camera?)
Const CR = 10
Const LF = 13
        
// read the AD port and scale for 0 - 5 volts, calc volt divider scale
Sub ADInAsVolt() 
   
   
   'using Vdd (5v) as ref, using 10k, 3.3K volt divider, actual volts / .33
   '5000 mvolts = 1024 counts 5000/1024 = 4.883 mvolts/count
   '1/.33 * mvolts = acutal volts before volt divider
   '100/33 = 1/.33
   
   CalVolts = ADC.Read(10) * 5000 / 1024   'read volts on an10 (AN1 input)
   ADMvolts(0) = (CalVolts * 100)/33
   CalVolts = ADC.Read(6) * 5000 / 1024   'read volts on an6 (AN2 input)
   ADMvolts(1) = (CalVolts * 100)/33   
   CalVolts = ADC.Read(5) * 5000 / 1024   'read volts on an5 (AN3 input)
   ADMvolts(2) = (CalVolts * 100)/33   
   CalVolts = ADC.Read(4) * 5000 / 1024   'read volts on an4 (AN4 input)
   ADMvolts(3) = (CalVolts * 100)/33   
End Sub

Sub SerialOut()
    USART.Write ("DATA,",PumpOn,",",ADMvolts(0),",",ADMvolts(0),",",ADMvolts(0),",",ADMvolts(0),CR,LF)
End Sub

'set oscilator options, internal 16MHz
OSCCON = %01110000       'use 16MHz internal oscilator, select HFINTOSC for FOSC

'set up analog pins
ADCON2 = %10000000      'right justified 10 bit results, Clock setup --- TAD = 0, FOSC/2
ADCON1 = %00000000      'using Vdd,Vss as ref
ADCON0 = %00000001      'turn on A/D unit
ANSEL = %01110000       'select an4,an5,an6 as analog
ANSELH = %00000100      'select an10 as analog

'set up tris bits
TRISB.7 = 0      'serial port out
TRISB.5 = 1      'serial port in
TRISB.6 = 0      'digital ouput
TRISB.4 = 1      'analog 10 input
TRISC.0 = 1      'analog 4 input
TRISC.1 = 1      'analog 5 input
TRISC.3 = 1      'analog 6 input

'set uart baud rate
SetBaudrate(br19200)

Low(DigOut)  'turn off digital output on boot

   
// main program loop...
While true                      
      'ADInAsVolt                'read the analog inputs
      If ADMvolts(0) >6000 Then     'over 6 volts says pump running
         If PumpOn = false Then
            SerialOut           'send analog values at pump start
            PumpOn = true
            High (DigOut)         'digital output on
         End If
      Else
          If PumpOn = true Then
              PumpOn = false
              SerialOut            'send analog values at pump stop
              Low (DigOut)           'digital output off)
          End If
     End If   
    DelayMS(500)    'wait 1/2 second  
Wend   

End
RD

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Wed Aug 12, 2009 3:12 am

RD,

I could not get your code to compile as well.
Even a simple blink code will not compile without errors.

But I think I know the problem. You need a newer version of the MPASMWin.exe that is located in the Bin folder.
On my computer I have MPLAB v8.0 (it is not the latest but) copy MPASMWin. exe from there to the bin folder.

Swordfish version was 5.11, MPLAB version is 5.14.
At least my blink compiles without errors so hopefully yours will too.

RKP

RDHeiliger
Registered User
Registered User
Posts: 26
Joined: Sun Oct 12, 2008 11:21 pm
Location: Utah

Post by RDHeiliger » Wed Aug 12, 2009 3:48 am

Your right.

I had MPLAB v8.1 in another directory, copied the MPASM file from there to the Swordfish Bin folder and the program compiled. Now i just need to make the board and see if it works.

Thanks!!!!!!!!!!!!!!

RD

speed64
Registered User
Registered User
Posts: 13
Joined: Mon Jul 09, 2007 10:45 am
Location: Germany Barßel

PIC18F14K50 and USB

Post by speed64 » Tue Dec 22, 2009 10:50 am

PIC18F14K50 and USB

Translation by Google, sorry.
Hello, the sheet says that the chip has a USB interface.
Unfortunately, he is disabled in the inludes file.
Can we change this with the new data from Microchip?
Here are some of the data sheet.
Universal Serial Bus Features:

Universal Serial Bus Features:
• USB V2.0 Compliant SIE
• Full Speed (12 Mb/s) and Low Speed (1.5 Mb/s)
• Supports Control, Interrupt, Isochronous and
Bulk Transfers
• Supports up to 16 Endpoints (8 bidirectional)
• 256-byte Dual Access RAM for USB
• Input-change interrupt on D+/D- for detecting
physical connection to USB host

I want to use this chip because it is the smallest with USB.

with best regards

Speed64

RDHeiliger
Registered User
Registered User
Posts: 26
Joined: Sun Oct 12, 2008 11:21 pm
Location: Utah

14K50 MPASM 5.33 Required

Post by RDHeiliger » Sat Feb 06, 2010 5:42 am

Just downloaded the latest update to the Swordfish compiler binary.

It replace my MPASM v5.33 with MPASM v5.11
v5.11 does not support the PIC18F14K50 parts.
results in hundreds of error messages.

Thought some might want to know this????

RD

plaressa
Posts: 2
Joined: Sat Jul 31, 2010 10:04 am

Post by plaressa » Mon Aug 02, 2010 12:28 pm

How to switch between USB speakers and headphones on vista? I just got usb speakers for my laptop. Sometimes i want to listen on the speakers and sometimes on the headphones. Is there any easy way to switch between them without having to unplug one, close the program, plug the other one in, re-open the program?
______________________________
external keyword tool ~ keyworddiscovery.com ~ keycompete.com ~ compete.com ~ webmasterworld.com
Last edited by plaressa on Sat Aug 07, 2010 7:05 am, edited 1 time in total.

DerekUnderlay
Posts: 4
Joined: Sat Jun 12, 2010 8:44 am
Location: UK

Post by DerekUnderlay » Mon Aug 02, 2010 12:43 pm

Mine switches perfectly without any need for faffing around. Maybe you have a duff notebook? Is it some cheap crap off Ebay. or, as this is your first post and non-Swordfish and non-PIC, are you going to spam us all?

Post Reply