Posts

Showing posts with the label microchip

Microchip Telnet Server fixes

I've been implementing a Telnet server on our products using the Microchip TCP/IP stack on a PIC18F87J50. Following are some useful notes! - The TCP/IP stack does not like being interrupted, especially by the USB stack if you have both of them compiled in together. I suggest you get your telnet working fully first before putting USB in place... I found issues with Stack overflows, processor lockup and lost Telnet data when using both at the same time! - If Telnet works but the socked does not disconnect properly when closed by the remote client, check you have initialised the Tick(TCP/IP timing) functions and have it correctly called in the interrupt routines! - Microchip have not bothered to implement Telnet properly. On connection a Telnet connection sends a bunch of options back and forwards to work out what each side can do. The Microchip example ignores these so you get 'junk' data on connection. HyperTerminal on windows sends 6 bytes of settings which the Microchip...

Accessing SD cards via SPI bus

There are various examples of accessing standard SD cards via the SPI bus (Microchip has one in their example code) but getting to the basics of how to implement your own is tricky! Here is a simple how-to, I've tried to show WHY you have to do certain things to make it clear what is happening.... - I'm assuming you have the SD card correctly connected onto the SPI bus and the chip select line (I'll call it CARD_CS) also setup correctly. [SPI BASICS] The SPI bus clock only runs while data is being clocked in/out. Data moves in both directions at the same time so if you clock 'out' byte 0xB3 you're 'in' buffer will change to whatever is on the input bus. If the device you are talking to did not send anything back at that time, the value will be 0x00. The SD card keeps things simple by (normally) not sending anything back until you have finished sending it a commend. This avoids the need to handle 'in' and 'out' comms at the same time... As...

Custom USB devices (Part 1)

I've recently been working on a series of custom designed USB devices. based on Microchip PIC processors (18F87J50 and 18F4550) and have a few observations to make for those doing similar things 1 - Get the Microchip USB firmware examples (MCHPFSUSB; search for "USB Stack" on their website). Some of the examples are pretty badly written but they are very useful for beginners. 2 - If you will ever have multiple devices of the same type attached at once you REALLY should add a unique serial number to each device. This is done by altering the USB descriptors. In my case, I set the number with a special command after the device has been programmed. The number is burned into ROM in the bootloader section so the user can never change it. If you don't have a serial number, Windows can get confused. In my case I had up to 28 devices that attach via a chain of USB hubs. If you connect them all at the same time, Windows will fail to find them all or may even blue screen. Addin...