Forum: Mikrocontroller und Digitale Elektronik PICkit 2 als serielle Schnittstelle, Logikanalysator unter Linux - wer kann libusb?


von Gast (Gast)


Lesenswert?

Ich brauch grad ne serielle Schnittstelle mit Logikpegeln, da ist mir 
das PICkit 2 eingefallen: http://www.microchip.com/PicKit2/

"UART Tool software for direct serial communications with a 
microcontroller RX/TX pins through the PICkit 2."

Allerdings läuft Linux. Es gibt da sogar was:
http://zwizwa.be/darcs/staapl/tools/
bzw.
http://zwizwa.be/darcs/staapl/tools/pk2serial.c (Tom Schouten)

braucht das Paket libusb-dev zum Bauen.

PICkit 2: ID 04d8:0033 Microchip Technology, Inc.
Firmware v2.32

Leider bekomme ich einen Fehler:

./pk2serial -v
baud rate = 9600
Can't set vendor config.

Kommt aus Z. 380 von pk2serial.c

Leider habe ich keine Ahnung von USB und bin daher auf Hilfe 
angewiesen..

Danke schonmal.

--
PS:
Es gibt anscheinend einen LA mit Python, habe ich aber noch nicht 
getestet:
http://sourceforge.net/projects/pk2-la/ (Joseph Jezak)

von Sergey (Gast)


Lesenswert?

Wenn du nur eine serielle Schnittstelle mit Logikpegeln brauchst, dann 
nimm doch einen FTDI.
Da gibt es auch Linux/OSX Treiber. Habe selbst einen perfekt unter OS X 
am Laufen, also sollte es unter Linux auch kein Problem geben.

von Gast (Gast)


Lesenswert?

Der Autor hat mich daran erinnert, dass der Zugriff auf USB nicht jedem 
gestattet ist. Leider habe ich auch als root nicht unbedingt Erfolg:

Ubuntu 8.10, 2.6.27-14-generic.

dmesg
... new full speed USB device using ehci_hcd ...

lsusb
... ID 04d8:0033 Microchip Technology, Inc.

PICkit firmware: PK2V023200.hex

sudo groupadd microchip
sudo usermod -a -G microchip USER
id USER
...,xxxx(microchip)

# /etc/udev/rules.d/026_microchip.rules
#PICkit2
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="0033", 
MODE="0666", GROUP="microchip", SYMLINK+="pickit2-%k"

Habe einige Varianten ausprobiert, bei Ubuntu ist wohl kürzlich ein 
neues udev eingesetzt worden und die Syntax hat sich geändert.

sudo /etc/init.d/udev reload

Aus-/Einstecken vom PICkit

ls /dev/pi*
/dev/pickit2-8-2.1.3

(mit BUS or SUBSYSTEMS gibt es 3 andere symlinks).

./pk2serial
Can't set vendor config.

Mit sudo bekomme ich keinen Fehler:

sudo ./pk2serial
_

aber auch nur das, was ich eintippe. Der Autor schreibt "serial console 
on stdio"
TX (pin 5) verbunden mit  RX (pin 4) bringt nichts.

Fragen:
 Warum funktionieren die udev rules nicht?
 Warum ergibt ein loopback mit sudo "./pk2serial -p" kein Echo?

"PICkit 2 Microcontroller Programmer User's Guide": 
http://www.microchip.com/Microchip.WWW.SecureSoftwareList/secsoftwaredownload.aspx?device=en023805&lang=en&ReturnURL=http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805&redirects=pickit2#

Hier die wichtigsten Infos:

  Pin Description*
> 1 = No Connect
  2 = VDD Target
  3 = VSS (ground)
  4 = RX (PICkit 2 In)
  5 = TX (PICkit 2 Out)
  6 = No Connect

150 to 38400 baud, including custom non-standard baud rates.

The PICkit 2 UART Tool will work with target VDD voltages from 2.5 Volts 
to 5.0 Volts.

The format of the serial signals on pins 4 and 5 is inverted such that a
Start Bit = logic low (VSS), and a Stop Bit = logic high (VDD). The 
serial data format is always 8 data bits, no parity, with one stop bit.

Even though PICkit 2 may not supply the target VDD, the PICkit 2 VDD pin
must be connected to the target VDD voltage or it will not be able to
communicate.

http://de.wikipedia.org/wiki/EIA-232

von Gast (Gast)


Lesenswert?

> Warum funktionieren die udev rules nicht?
Aus- und Einloggen (Gruppenrechte).

> Warum ergibt ein loopback mit sudo "./pk2serial -p" kein Echo?

"  Anything that gets sent to the stdin of the program goes to the TX 
pin,
   and everything that comes from RX pin goes to stdout of the program.
   Note that you need to make sure that there are no buffering issues."

http://www.dest-unreach.org/socat/doc/socat.html

$ socat EXEC:./pk2serial /dev/ttyS0,raw,echo=0,crnl,b9600
2009/08/31 13:17:03 socat[13252] E tcgetattr(5, 0xbffdb758): 
Input/output error


Mhh.

von Gast (Gast)


Lesenswert?

Ich bin vielleicht ein Gast!
Wär' gut, wenn man die Tastatureingabe auch per RETURN an stdin sendet..
Dann geht's auch ohne socat..

von Gast (Gast)


Lesenswert?

Eine Datei mit 38400 baud senden:
cat file | ./pk2serial -b 38400

von Gast (Gast)


Lesenswert?

socat kann pseudo-gerätedateien als symlink herstellen. stichwort PTY.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.