New storage temperature monitoring

med_ek-tm4c1294xl_clp-top-no-shadow-low_resOld arm board I was using to monitor my storage temperature broke. As I didn’t have any similar boards in my piles any more, I decided that this would be a great opportunity to try something more modern instead. New board should be using a Cortex-M3/M4 CPU, have ethernet controller on board and a few GPIO pins for 1-wire interface. At the end I had two choices: either Olimex STM32-E407 or Texas instruments Tiva Connected Launchpad.

As I really liked TI’s stuff on MSP430 microcontrollers before I decided to try Tiva launchpad.(Olimex does’t offer TI Cortex-M4 boards currently)

I had earlier ported Pico]OS to Tiva Launchpad, but I still had some problems in getting simple blink-a-led stuff running. I finally found out that chip on this board requires different clock setup than the one on simpler launchpad (one must call SysCtlClockFreqSet instead of SysCtlClockSet & SysCtlClockGet). The basic uIP driver for ethernet was provided as an example with tivaware and it was very easy to adapt it from there into picoos-net library.

I refactored by existing sensor-web project quite heavily by moving all board-specific stuff into separate subdirectories, hoping that project wouldn’t look like a big mess after adding new board (it now supports old Olimex LPC-E2129 arm7 board, Tiva launchpad and unix for testing). As Tiva board has more RAM than old board, it was possible to allow more concurrent tcp/ip connections, which makes the web browser interface to work a lot better than with just 2 connections.

I put the board into plastic box today and moved it into storage room. Temperature trends from it are available here.

 

Wifi for picoos-net & uIP

Picoos-net library has been lacking support for Wifi networks and I have been trying to figure out how to implement it.

I would like to run the network stack on the microcontroller along with my application so I could keep on using APIs I’m familiar with. This rules out modules that have built-in tcp/ip networking. However, writing whole Wifi stack would be a huge task and resulting library might be too big for some microcontrollers I have been using. So this rules out cheap usb-stick style approach.

hlk-rm04Microchip has a nice Wifi module, but documentation for it is not publicly available and their own network stack is limited (by license) for use with their own microcontrollers only.

Broadcom seems to have nice modules also (Wiced) and they seem to provide some kind of SDK, which might make integration of modules easier.

Continue reading “Wifi for picoos-net & uIP”

BSD sockets for uIP / picoos-net

When I wrote the “native” picoos-net socket API I focused mostly on simplicity and efficiency to avoid adding too much weight to uIP. Although this layer has worked well for me, it is incompatible with BSD socket API available on many platforms. Incompatibility makes re-using code from other environments like lwIP or unix/linux (or even Texas Instruments CC3000 chip) difficult. Because I wanted to use some of my Pico]OS stuff with lwIP or CC3000 also, I decided to add a simple BSD socket layer to picoos-net library.

It contains currently following functions:


int net_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int net_bind(int s, const struct sockaddr *name, socklen_t namelen);
int net_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
int net_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
int net_close(int s);
int net_connect(int s, const struct sockaddr *name, socklen_t namelen);
int net_listen(int s, int backlog);
int net_recv(int s, void *mem, size_t len, int flags);
int net_send(int s, const void *dataptr, size_t size, int flags);
int net_socket(int domain, int type, int protocol);
int net_read(int s, void *mem, size_t len);
int net_write(int s, const void *dataptr, size_t size);

Library includes similar compatibility system like lwIP has for standard BSD socket api:

  • if NETCFG_COMPAT_SOCKETS is defined as 1 then defines for standard BSD socket functions are added to translate calls to net_* -functions, ie. accept() is defined as net_accept.
  • If NETCFG_POSIX_SOCKETS_IO_NAMES is defined as 1 then defines for read, write and close functions are also added.

setsockopt options are mostly ignored, however SO_RCVTIMEO can be used to set read timeout.

Tiva C Launchpad

launchpad-tivac-01I added an example about how to run Pico]OS on Texas Instruments Tiva C Launchpad, which is a very affordable Cortex-M4 evaluation board. It costs currently less than $13 and has 256 Kb of flash and 32 Kb of ram.

Supporting it wasn’t quite as easy as I thought. Texas Instruments provides a C-language library called ‘Tivaware’ which contains functions to access all peripherals provided by the chip. However, tivaware does not include CMSIS headers currently (I was using version 2.x), which makes porting software that uses CMSIS (like Pico]OS) more difficult than it would otherwise be. Continue reading “Tiva C Launchpad”

Pico]OS & NXP DIP Arms

lpc800_dip8In the past, ARM microcontrollers have been available only in packages which are rather unfriendly for hobbyist use. However, NXP is now producing two Cortex-M0 microcontrollers in DIP packages, which are very handy for breadboard use and trough-hole soldering. The chips are LPC1114 in DIP28 package and LPC810 in DIP8 package. LPC1114FN28/102 has 32 kB flash and 8 kB ram, which is actually quite nice and allows running even a small RTOS. LPC810M021FN8 has only 4 kB flash and 1 kB ram, which is not much but still suitable for small bare metal applications. Continue reading “Pico]OS & NXP DIP Arms”