Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - mark

Pages: 1 ... 4 5 [6] 7 8 ... 19
76
NXPTM M522XX, KINETIS and i.MX RT / CodeWarrior 10 uTasker User's Guide
« on: December 14, 2012, 01:00:46 AM »
Hi All

I have just added the following document:
http://www.utasker.com/docs/KINETIS/uTasker_CodeWarrior10.pdf

This is a short guide about how new projects are created in CodeWarrior 10 (based on Kinetis but suitable also for Coldfire). It may not be the best method but it may serve as useful reference when setting up new projects.

Regards

Mark

77
Hi All

After spending more hours trying to identify a problem than I would have liked to I am wondering whether the reason for the problem was bad coding or bad compiling? It failed only with GCC.

This is the line that cost half a day of troubles:

present_task->ulTaskPresentIndex += fnSubroutine(present_task->ulTaskPresentIndex, (void *)present_task); // move to next index

The value present_task->ulTaskPresentIndex is passed to the routine as a value but also a pointer is passed (but declared void) which allows the subroutine to manipulate the same value (present_task->ulTaskPresentIndex) in a particular instance. The return value is used to increment the index with a certain index step.

In the one case where present_task->ulTaskPresentIndex is modified in the subroutine it fails and the following was found to be happening.
- when the subroutine was called present_task->ulTaskPresentIndex was pushed to the stack as passing parameter
- the subroutine modified present_task->ulTaskPresentIndex via the present_task pointer (casted in the subroutine to the same struct pointer type)
- when the subroutine returns it does a pop and also pops back the original present_task->ulTaskPresentIndex value from the stack to the present_task->ulTaskPresentIndex - which is in a register. This means that the change made in the subroutine was cancelled out and the index was then incorrect and written to the 'real' present_task->ulTaskPresentIndex in RAM

The following change worked around this "problem":

int iShift = fnSubroutine(present_task->ulTaskPresentIndex, (void *)present_task);
present_task->ulTaskPresentIndex += iShift;


I can't work out whether it is bad programming or a compiler problem - it didn't make any difference whether optimisation was enabled or not.

Can any compiler experts comment on this and give a rule for programmers to avoid such potential issues?

Regards

Mark




78
ATMELTM AT91SAM7X and AVR32 / Reading the silicon revision of AVR32 devices
« on: September 08, 2012, 07:04:28 PM »
Hi All

If anyone needs to be sure of the silicon revision in the AVR32 the following command gives details when connected to a board via JTAG debugger:

avr32program cpuinfo

The output from the program looks something like this:

Connected to JTAGICE mkII version 7.25, 7.25 at USB.

Device information:
  Device Name                                   UC3A0512
  Device Revision                               I
  JTAG ID                                       0x81edc03f
  SRAM size                                     64 kB
  Flash size                                    512 kB


Regards

Mark


79
NXPTM LPC2XXX and LPC17XX / LPC2xxx Ethernet reliability
« on: September 01, 2012, 08:56:49 PM »
Hi All

I have experienced a number of LPC2xxx based projects with Ethernet that have a tendency to lose some Ethernet transmissions. Not a huge loss, but at maybe 1/100'000 it is much higher that is usual in a local network.

I have linked to a thread where there are hardware details of a potential improvement/correction in some cases. Probably specific to a certain PHY but it may prove of use to anyone who has similar problems:

http://tech.groups.yahoo.com/group/lpc2000/message/57791

Regards

Mark

80
µTasker general / A tail of two brackets
« on: September 01, 2012, 08:36:19 PM »
Hi All

This one is mainly to remind myself to be more careful...

When porting some code from a project using a routine called __modu(x, y), which was a standard modulo function but not available in the target's library the simple solution was to add a macro:
#define __modu(x, y) (x%y)

The new project was soon up and running and delivered for testing and things looked good apart from one quirky piece of behaviour that was quite hard to reproduce.

After some lengthy testing and debugging the cause of the problem was homed in on and it was noticed that this modu() function/macro was not always working correctly. In particular some code doing
int var = __modu(x + z, y); was not always giving the expected result (sometime it was corect but sometime not).

Soon it became clear that the macro was to blame. Whereas the code was fine when calling a subroutine, the macro was doing:
var = (x + z%y); which is actually not want was intended since y%z has priority.
Correct would have been:
var = ((x + z)%y);

So the macro was modified to
#define __modu(x, y) ((x)%(y))
and everyone, including the software, was happy.

So the moral is to be careful (warning to myself) since typing in a couple of brackets at the beginning can quite easly save a day of unnecessary work later. Probably a beginner's mistake in many people's book but probably even more experienced programmers do get caught out now and again...;-)

Regards

Mark

81
Hi All

The Kinetis has an Ethernet EMAC peripheral (when available) based on the one used in the Coldfire but with some extensions. The EMAC is based on buffer descriptors which are created and controlled in SRAM and these buffer descriptors work basically in big-endian mode. This suited the Coldfire but required some big / little-endian swapping in code when used with the Cortex M4 based Kinetis.

It happens that the K70 and K61 derivatives now allow the endian mode to be configured so that the buffer descriptors can operate in the more natural (for the ARM) mode which saves having to do this swapping in code and there results in a small improvement in the code efficiency. Although maybe not a huge saving every bit helps and so the following change has been made to make use of this capability.

1) When the chip supports this it will have an extra bit called ETHER_DBSWP in the EMAC ECR register. Therefore this bit is made conditional on the processor used:

#define ECR                  *(volatile unsigned long *)(EMAC_BASE_ADD + 0x24) // Ethernet Control Register
  #define RESET_FEC          0x00000001                                  // issue MAC reset (self-clearing)
  #define ETHER_EN           0x00000002                                  // enable ethernet operation
  #define ETHER_MAGICEN      0x00000004                                  // enable magic package detection
  #define ETHER_SLEEP        0x00000008                                  // enable sleep mode
  #define ETHER_EN1588       0x00000010                                  // enable enhanced functionality
  #define ETHER_DBGEN        0x00000040                                  // enter freeze mode when debuggig
  #define ETHER_STOPEN       0x00000080                                  // enabled in doze mode
#if defined KINETIS_K61 || defined KINETIS_K70
  #define ETHER_DBSWP        0x00000100                                  // enabled descriptor byte swapping to support little-endian devices
#endif


2) Then the definitions of the buffer descriptors and their content are conditional on the presence of the bit:

#if defined ETHER_DBSWP                                                  // natural little-endian
    typedef struct stKINETIS_FEC_BD
    {
        volatile unsigned short usBDLength;
        volatile unsigned short usBDControl;
        unsigned char *ptrBD_Data;
    #ifdef EMAC_ENHANCED                                                 // additional fields available in enhanced mode
        volatile unsigned long  ulBDControlEnhanced;
        volatile unsigned short usPayloadCS;                             // only receiver
        volatile unsigned short usRxInfoHeaderProt;                      // only receiver
        volatile unsigned long  ulBDU;
        volatile unsigned long  ul1588_timestamp;
        unsigned long  ulRes[2];
    #endif
    } KINETIS_FEC_BD;

    #define EMPTY_BUFFER         0x8000                                  // RX BD Control bits
    #define RECEIVE_OWNERSHIP_1  0x4000                                  // can be optionally used by software
    #define WRAP_BIT_RX          0x2000
    #define RECEIVE_OWNERSHIP_2  0x1000                                  // can be optionally used by software
    #define LAST_IN_FRAME_RX     0x0800
    #define RECEIVE_MISS         0x0100                                  // received due to promiscuouse mode only
    #define RECEIVE_BROADCAST    0x0080                                  // received due to broadcast address
    #define RECEIVE_MULTICAST    0x0040                                  // received due to multicast address
    #define RECEIVE_LENGTH_VIOL  0x0020                                  // receive frame length violation
    #define RECEIVE_NON_OCTET_AL 0x0010                                  // non-octet aligned frame
    #define RECEIVE_CRC_ERROR    0x0004                                  // receive CRC or frame error
    #define OVERRUN_FRAME        0x0002
    #define TRUNCATED_FRAME      0x0001

    // Enhanced
    //
    #define RX_MAC_ERROR         0x80000000
    #define RX_PHY_ERROR         0x04000000
    #define RX_COLLISION         0x02000000
    #define RX_UNICAST           0x01000000
    #define RX_GEN_INTERRUPT     0x00800000
    #define RX_IP_CS_ERROR       0x00000020
    #define RX_PROT_CS_ERROR     0x00000010
    #define RX_VLAN              0x00000004
    #define RX_IPV6              0x00000002
    #define RX_IPV4_FRAG         0x00000001

    #define RX_HEADER_LEN_MASK   0xf800
    #define RX_PROT_TYPE_MASK    0x00ff


    #define READY_TX             0x8000                                  // TX BD Control bits
    #define TRANSMIT_OWNERSHIP_1 0x4000                                  // can be optionally used by software
    #define WRAP_BIT_TX          0x2000
    #define TRANSMIT_OWNERSHIP_2 0x1000                                  // can be optionally used by software
    #define LAST_IN_FRAME_TX     0x0800
    #define TX_CRC               0x0400
    #define TX_ABC               0x0200                                  // append bad CRC - not supported in enhanced mode

    // Enhanced
    //
    #define TX_GENERATE_INT      0x40000000
    #define TX_ADD_TIMESTAMP     0x20000000
    #define TX_INSERT_PROT_CS    0x10000000
    #define TX_INSERT_IP_CS      0x08000000
    #define TX_ERROR_OCCURRED    0x00008000
    #define TX_UNDERFLOW_ERROR   0x00002000
    #define TX_EXCESS_COLLISIONS 0x00001000
    #define TX_FRAME_ERROR       0x00000800
    #define TX_LATE_COLLISION    0x00000400
    #define TX_OVERFLOW_ERROR    0x00000200
    #define TX_TIMESTAMP_ERROR   0x00000100

    #define BD_UPDATE_DONE       0x80000000                              // rx and tx

#else                                                                    // big-endian representation
    typedef struct stKINETIS_FEC_BD
    {
        volatile unsigned short usBDControl;
        volatile unsigned short usBDLength;
        unsigned char *ptrBD_Data;
    #ifdef EMAC_ENHANCED                                                 // additional fields available in enhanced mode
        volatile unsigned long  ulBDControlEnhanced;
        volatile unsigned short usRxInfoHeaderProt;                      // only receiver
        volatile unsigned short usPayloadCS;                             // only receiver
        volatile unsigned long  ulBDU;
        volatile unsigned long  ul1588_timestamp;
        unsigned long  ulRes[2];
    #endif
    } KINETIS_FEC_BD;

    #define EMPTY_BUFFER         0x0080                                  // RX BD Control bits
    #define RECEIVE_OWNERSHIP_1  0x0040                                  // can be optionally used by software
    #define WRAP_BIT_RX          0x0020
    #define RECEIVE_OWNERSHIP_2  0x0010                                  // can be optionally used by software
    #define LAST_IN_FRAME_RX     0x0008
    #define RECEIVE_MISS         0x0001                                  // received due to promiscuouse mode only
    #define RECEIVE_BROADCAST    0x8000                                  // received due to broadcast address
    #define RECEIVE_MULTICAST    0x4000                                  // received due to multicast address
    #define RECEIVE_LENGTH_VIOL  0x2000                                  // receive frame length violation
    #define RECEIVE_NON_OCTET_AL 0x1000                                  // non-octet aligned frame
    #define RECEIVE_CRC_ERROR    0x0400                                  // receive CRC or frame error
    #define OVERRUN_FRAME        0x0200
    #define TRUNCATED_FRAME      0x0100

    // Enhanced
    //
    #define RX_MAC_ERROR         0x00000080
    #define RX_PHY_ERROR         0x00000004
    #define RX_COLLISION         0x00000002
    #define RX_UNICAST           0x00000001
    #define RX_GEN_INTERRUPT     0x00008000
    #define RX_IP_CS_ERROR       0x20000000
    #define RX_PROT_CS_ERROR     0x10000000
    #define RX_VLAN              0x04000000
    #define RX_IPV6              0x02000000
    #define RX_IPV4_FRAG         0x01000000

    #define RX_HEADER_LEN_MASK   0x00f8
    #define RX_PROT_TYPE_MASK    0xff00


    #define READY_TX             0x0080                                  // TX BD Control bits
    #define TRANSMIT_OWNERSHIP_1 0x0040                                  // can be optionally used by software
    #define WRAP_BIT_TX          0x0020
    #define TRANSMIT_OWNERSHIP_2 0x0010                                  // can be optionally used by software
    #define LAST_IN_FRAME_TX     0x0008
    #define TX_CRC               0x0004
    #define TX_ABC               0x0002                                  // append bad CRC - not supported in enhanced mode

    // Enhanced
    //
    #define TX_GENERATE_INT      0x00000040
    #define TX_ADD_TIMESTAMP     0x00000020
    #define TX_INSERT_PROT_CS    0x00000010
    #define TX_INSERT_IP_CS      0x00000008
    #define TX_ERROR_OCCURRED    0x00800000
    #define TX_UNDERFLOW_ERROR   0x00200000
    #define TX_EXCESS_COLLISIONS 0x00100000
    #define TX_FRAME_ERROR       0x00080000
    #define TX_LATE_COLLISION    0x00040000
    #define TX_OVERFLOW_ERROR    0x00020000
    #define TX_TIMESTAMP_ERROR   0x00010000

    #define BD_UPDATE_DONE       0x00000080                              // rx and tx
#endif


Note that the buffer descriptor content is swapped between little-and big-endian and also some of the elements in the KINETIS_FEC_BD struct have a different ordering to suit.

3) When accesses to some buffer descriptor values (like data length and address pointers) are made macros are used which are defined as below. When the buffer decriptors can work in little-endian mode the macros are simply made to directly use the value without any extra work:

#if defined _WINDOWS || defined ETHER_DBSWP                              // device with ETHER_DBSWP control in the ECR register can configure the EMAC buffer decriptors to use little-endian mode
    #define fnLE_ENET_add(x)  x
    #define fnLE_ENET_word(x) x
#else
    // Convert between little and big-endian address
    //
    #define fnLE_ENET_add(x) (unsigned char *)(((unsigned long)(x) >> 24) | (((unsigned long)(x) >> 8) & 0x0000ff00) | (((unsigned long)(x) << 8) & 0x00ff0000) | (((unsigned long)(x) << 24) & 0xff000000))

    // Convert between little and big-endian short word
    //
    #define fnLE_ENET_word(x) (((unsigned short)(x) >> 8) | ((unsigned short)(x) << 8))
#endif


4) Finally, when the Ethernet operation is enabled - or re-enabled, the little-endian mode is selected by

ECR = ENABLE_ETHERNET_OPERATION;

where the value of ENABLE_ETHERNET_OPERATION is made conditional on whether enhanced mode is used or whether the chip supports the little-endian mode by using the following:

#ifdef EMAC_ENHANCED
    #if defined ETHER_DBSWP                                              // if the EMAC supports buffer descriptors in little-endian format enable this mode
        #define ENABLE_ETHERNET_OPERATION (ETHER_EN | ETHER_EN1588 | ETHER_DBSWP)
    #else
        #define ENABLE_ETHERNET_OPERATION (ETHER_EN | ETHER_EN1588)
    #endif
#else
    #if defined ETHER_DBSWP                                              // if the EMAC supports buffer descriptors in little-endian format enable this mode
        #define ENABLE_ETHERNET_OPERATION (ETHER_EN | ETHER_DBSWP)
    #else
        #define ENABLE_ETHERNET_OPERATION (ETHER_EN)
    #endif
#endif


Therefore by changing a few defines K70 and K61 processors automatically take advantage of this capability...

Good luck!

Regards

Mark

P.S. The above has been tested and will be automatically included in the next Kinetis project release.


82
µTasker general / IPv4/IPv6 on-line demo
« on: August 06, 2012, 10:02:46 AM »
Hi All

Finally I got around to updating the on-line demo to also show IPv6 operation on a global IPv6 address.

To contact an EVK1105 over IPv4 the address http://demo.utasker.com can be used which resolves to its IPv4 address
To contact it over IPv6 (if you can ;-) its fixed address is http://[2001:470:26:105::99]

Note that the board is also performing 6in4 tunneling for other devices (and my computer) on the LAN so that these can also operate in IPv6 mode via my IPv4-only provider.

Regards

Mark

83
µTasker general / Multi-homed network and multiple interfaces
« on: July 19, 2012, 11:50:22 PM »
Hi All

Furure versions uTasker project will support multi-homed networking and multiple interfaces and the following describes how to modify existing projects for compatibility with the newer versions with these features. This description is linked to in the release notes where "multiple interface and multiple network support" has been added.

Regards

Mark


**************************************************************************************************

The uTasker project has new support for mult-homed networking. This means that the TCP/IP stack can handle multiple networks and also multiple interface (including multiple interfaces in each network)
This new support required a few adjustments that affect the original definitions.
The following is a step by step explanation about making existing projects compatible with the new use if multi-network/interface operation is not required:


1)
Oringinally NETWORK_PARAMETERS network; (and network_flash) was a single network struct holding the IP defauls of the single network
New: NETWORK_PARAMETERS network[IP_NETWORK_COUNT]; this should now be defined as an array of network structs, whereby IP_NETWORK_COUNT defaults to 1

2)
All uses of network (and network_flash) need to be changed to network[DEFAULT_NETWORK], whereby DEFAULT_NETWORK defaults to 0

3) The interface fnGetARPentry() has been changed to be more flexible

Rather than returning either the IP or MAC address in an ARP cache entry it returns a pointer to the netry so that more infomration can be displayed.
extern unsigned char *fnGetARPentry(unsigned char ucEntry, int iIP_MAC);
has been changed to
extern ARP_TAB *fnGetARPentry(unsigned char ucEntry, int iIP_MAC);

This means that routines no longer pass the requested information but instead extract the required part from the ARP_TAB pointer. For example:

cPtr = (CHAR *)fnGetARPentry((unsigned char)(*ptrBuffer - 'a'), GET_IP); // get pointer to IP address

becomes

ARP_TAB *PtrEntry = fnGetARPentry((unsigned char)(*ptrBuffer - 'a')); // get pointer to ARP entry
cPtr = PtrEntry->ucIP;




The three changes above are adequate to make existing projects fully compatible.





To use the new features the following steps can be followed:

1) Change the number of networks by adding the following define with the number required (example 2)
#define IP_NETWORK_COUNT 2

2) Add a define for the second network (remembering that the default network defaults to 0)
#define SECOND_NETWORK   1    // next network number

3) Add the configuration of the second network (the first one is already configured). For example add a second default set:

static const NETWORK_PARAMETERS network_default_2 = {
    (AUTO_NEGOTIATE /*| FULL_DUPLEX*/ | RX_FLOW_CONTROL),                // usNetworkOptions - see driver.h for other possibilities
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},                                // ucOurMAC - when no other value can be read from parameters this will be used
    { 192, 168, 2, 2 },                                                  // ucOurIP - our default IP address
    { 255, 255, 255, 0 },                                                // ucNetMask - Our default network mask
    { 192, 168, 2, 1 },                                                  // ucDefGW - Our default gateway
    { 192, 168, 2, 1 },                                                  // ucDNS_server - Our default DNS server
#ifdef USE_IPV6
    { _IP6_ADD_DIGIT(0x2001), _IP6_ADD_DIGIT(0x0470), _IP6_ADD_DIGIT(0x0026), _IP6_ADD_DIGIT(0x0105), _IP6_ADD_DIGIT(0x0000), _IP6_ADD_DIGIT(0x0000), _IP6_ADD_DIGIT(0x0000), _IP6_ADD_DIGIT(0x0020) }, // default global IPV6 address
    #if defined USE_IPV6INV4
    { 216, 66, 80, 98 },                                                 // IPv6 in IPv4 tunnelling enabled when the tunnel address is not 0.0.0.0
    #endif
#endif
};

and then initialise the second set with it if no defaults are already available:

            fnSetDefaultNetwork(&network[DEFAULT_NETWORK]);              // if no parameters are available, load the default set
            fnSetDefaultNetwork2(&network[SECOND_NETWORK]);              // load defaults for second network

where:
extern void fnSetDefaultNetwork2(NETWORK_PARAMETERS *ptrNetPars)
{
    uMemcpy(ptrNetPars, &network_default_2, sizeof(NETWORK_PARAMETERS));
}


Now the second network has its own configuration.

4) If there is a second network it needs to be attached to another interface. That means that a second interface must also be defined.
#define IP_NETWORK_COUNT 2   // two interfaces in the system

Assuming that there are two Ethernet interfaces controlled by the processor each must be opened and their handle entered as follows:

Ethernet_handle = fnOpen(TYPE_ETHERNET, FOR_I_O, &ethernet);
fnEnterInterfaceHandle(DEFAULT_IP_INTERFACE, Ethernet_handle);
Ethernet_handle_2 = fnOpen(TYPE_ETHERNET, FOR_I_O, &ethernet);
fnEnterInterfaceHandle(SECOND_IP_INTERFACE, Ethernet_handle_2);

Where the additional interface has its own number (DEFAULT_IP_INTERFACE default is 0)
#define SECOND_IP_INTERFACE        1        // next interfacenumber


5) Receiving on a new interface depends on its type (it could be Ethernet or it could be another adapter like Wifi, serial etc. but with Ethernet conform content).
The important this is that all received data passed to the TCP/IP stack are pass with the following fields set to math the interface and its network:

ETHERNET_FRAME rx_frame;
.. set up frame content
rx_frame.ucNetworkID = SECOND_NETWORK;                                // mark that frame arriving on this interface belong to the second network
rx_frame.Tx_handle = Ethernet_handle_2;                               // mark the interface handle to be used when responding
..
fnHandleIP_protocol(rx_frame.ptEth->ucData[IPV4_PROTOCOL_OFFSET], &rx_frame); // pass frame to IP

The TCP/IP stack now known which network the data belongs to and also which interface to send any responses to.

6) When the user establishes connections or sends data this will default take place on the default interface on the default network.
To define that this should be on a different network and using a corresponding interface the user controls it with its socket number. All UDP and TCP 'connection' use a socket so their basic operation. Also ICMP can use a 'virtual' socket for identification purposes during its use.

The basic socket definition (in types.h) is as follows:
typedef signed char        USOCKET;
This allows up to 127 sockets (127 UDP and 127 TCP) to be maintained.
The following shows how the socket with is made 15 bit and then the network and interface(s) belonging to each socket are coded into it. The example shows a configuration supporting 2 networks and 3 interfaces but many more could be coded into the socket without restricting the number of sockets possible.

// TCP/IP support
//
typedef signed char        USOCKET;                                      // socket support from 0..32767 (negative values are errors) - some bits used to identify network and interface


// Multi-network/interface socket control
//
#define NETWORK_SHIFT        14                                          // valid for just 2 networks and USOCKET as signed short
#define NETWORK_MASK         0x01
#define INTERFACE_SHIFT      11                                          // valid for up to 3 interfaces and USOCKET as signed short
#define INTERFACE_MASK       0x07
#define SOCKET_NUMBER_MASK   0x7ff

/*------------------------------------------------------------------*/
/* V | N | I2 | I1 | I0 | S | S | S | S | S | S | S | S | S | S | S */
/*------------------------------------------------------------------*/

// V = valid socket
// N = Network (0 / 1) that the socket can use - there are two networks available
// Ix = flags for each interface that the socket can use I0, I1, I2 means that there are 3 physical sockets available (2 in one network and 1 in the other)
// S = socket number from 0..0x7ff
// note that USOCKET has been chosen as signed short to give adequate width


7) The networks and interfaces can now be defines accoring to project use with help from the following macros (this can be added in config.h after the inclusion of types.h):

// Multi-network/interface socket control - see types.h for the configuration
//
#define PRIMARY_NETWORK_SOCKET      defineNetwork(DEFAULT_NETWORK)
#define SECONDARY_NETWORK_SOCKET    defineNetwork(SECOND_NETWORK)

#define PRIMARY_INTERFACE           defineInterface(DEFAULT_IP_INTERFACE)
#define SECONDARY_INTERFACE         defineInterface(SECOND_IP_INTERFACE)

8 ) The following sends a ping to the first network (default)
fnSendPing(ping_address, MAX_TTL, OWN_TASK, dummy_socket);
which is equivalent to
fnSendPing(ping_address, MAX_TTL, OWN_TASK, (dummy_socket | PRIMARY_NETWORK_SOCKET | PRIMARY_INTERFACE));

Therefore to direct it to the second interface the socket is simply set with the specific socket details
fnSendPing(ping_address, MAX_TTL, OWN_TASK, (dummy_socket | SECONDARY_NETWORK_SOCKET | SECONDARY_INTERFACE));


Note that, if there are multiple interface on the second network only the defined interface will be used for discovering the IP address if it is not already resolved.
To cause address resolution to take place on all (or a defined sub-set of) the interfaces each interface can be individually specified - eg.
fnSendPing(ping_address, MAX_TTL, OWN_TASK, (dummy_socket | SECONDARY_NETWORK_SOCKET | SECONDARY_INTERFACE | TERTIARY_INTERFACE));


*****************************************************************

84
Hi All

It seems as though some CW10.2 builds have a problem with the linker requiring a particular symbol called __SP_INIT even when this is not required by the project.

See the following for more details: http://forums.freescale.com/t5/CodeWarrior-General/SP-INIT-and-the-library-FP-fixedI-Thumb-LE-v7M-a-CW10-2-SE/m-p/103317#M9233

In case of a linking problem due to a missing symbol called __SP_INIT simply add a dummy symbol to the linker script file (eg.):


} >> sram
__text_load_start__ = ___DATA_ROM;
__text_start__ = __text_load_start__;
__text_end__ = __text_load_start__;
__data_start__ = ___DATA_RAM;
__data_load_start__ = __text_load_start__;
__data_end__ = ___DATA_END;
__bss_start__ = __START_BSS;
__bss_end__= ___BSS_END;
__heap_end__ = __bss_end__;
__SP_INIT = __bss_end__;
}


Presumably the actual value is not important.

Regards

Mark




85
NXPTM M522XX, KINETIS and i.MX RT / Some ADC notes on M522xx
« on: May 06, 2012, 02:55:10 PM »
Hi All

In addition to the following two threads
http://www.utasker.com/forum/index.php?topic=280.0
http://www.utasker.com/forum/index.php?topic=437.0
the following discusses how to configure for a scan of all channels and a single interrupt on completion.

To set up for a sequential scan of all inputs and then an interrupt (just once) the following can be used:

    ADC_SETUP adc_setup;                                                 // interrupt configuration parameters
    adc_setup.int_type = ADC_INTERRUPT;                                  // identifier when configuring
    adc_setup.int_handler = adc_result_ready;                            // handling function
    adc_setup.int_priority = ADC_ERR_PRIORITY;                           // ADC interrupt priority
    adc_setup.int_adc_int_type = 0;
    adc_setup.int_adc_mode = (ADC_CONFIGURE_CHANNEL | ADC_CONFIGURE_ADC | ADC_CONFIGURE_CHANNEL | ADC_SEQUENTIAL_MODE | ADC_SINGLE_ENDED);
    adc_setup.int_adc_speed = (unsigned char)(ADC_SAMPLING_SPEED(5000000));// 5MHz sampling (must be between 100kHz and 5MHz)
    adc_setup.int_adc_result = 0;                                        // no result is requested

    adc_setup.int_adc_bit = 0;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure ADC and channel 0
    adc_setup.int_adc_mode = (ADC_CONFIGURE_CHANNEL);
    adc_setup.int_adc_bit = 1;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 1
    adc_setup.int_adc_bit = 2;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 2
    adc_setup.int_adc_bit = 3;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 3
    adc_setup.int_adc_bit = 4;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 4
    adc_setup.int_adc_bit = 5;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 5
    adc_setup.int_adc_bit = 6;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 6
    adc_setup.int_adc_bit = 7;
    adc_setup.int_adc_int_type = (ADC_END_OF_SCAN_INT | ADC_SINGLE_SHOT_TRIGGER_INT); // interrupt types
    adc_setup.int_adc_mode = (ADC_START_OPERATION | ADC_CONFIGURE_CHANNEL);
    fnConfigureInterrupt((void *)&adc_setup);                            // configure channel 7 and start conversion


This configures the ADC (its speed and basic mode) and each channel.
Notice that at the end the interrupt is also added – a single shot one at the end of the scan. The operation is also started.

The interrupt call back adc_result_ready() is called by the interrupt. Often this is used to schedule a task that will then read and handle the values
 
// This interrupt is called when the ADC level changes below programmed threshold (on one of the enabled channels)
//
static void adc_result_ready(ADC_INTERRUPT_RESULT *adc_result)
{
    fnInterruptMessage(OWN_TASK, ADC_LOW_0);
}



The following shows the handling reading all values to the ucResults[] array and displaying just one of them – it could of course display more. Then it starts a timer which is used to repeat the exercise at regular intervals.

    ADC_SETUP adc_setup;                                 // interrupt configuration parameters
    ADC_RESULTS results;
    adc_setup.int_type = ADC_INTERRUPT;                  // identifier
    adc_setup.int_priority = ADC_ERR_PRIORITY;           // port interrupt priority
    adc_setup.int_adc_result = &results;
    adc_setup.int_adc_bit = 7;                           // ADC bit 7
    fnDebugMsg("Temperature value = ");
    adc_setup.int_adc_mode = (ADC_READ_ONLY | ADC_ALL_RESULTS);// start operation now and return the present result
    fnConfigureInterrupt((void *)&adc_setup);            // enter interrupt for low level trigger
    fnDebugHex(results.sADC_value[7], (WITH_SPACE | WITH_LEADIN | WITH_CR_LF | 2));
    uTaskerMonoTimer( OWN_TASK, (DELAY_LIMIT)(10.0 * SEC), E_NEXT_SAMPLE );



The simulator can be used to task the basic operation (it is quite accurate and so if it works there is will very probably work on the HW – if it doesn’t it will probably also not work on the HW and can be debugged before making the next step.

The ADC interface supports most (or all) modes of ADC operation. It can be either used directly or, if the code is to be optimally efficient, the registers that it sets up (and values) can be checked and then copied to user code in the same sequence with the same values.
The single-shot operation powers down the ADCs once the scan is completed, so the ADCs need to be powered and initialised each time.


The mode names should match with the modes supported by the ADC. They won’t necessarily match with bits in registers since they are used to inform the initialisation part of the ADC interface to control appropriate parts.
Some important mode flags:
ADC_CONFIGURE_ADC      - the main ADC mode is set (this needs to be set only one after the ADC is initialised/powered up)
ADC_CONFIGURE_CHANNEL  - the specified ADC channel will be initialised (also port pins configure appropriately)
ADC_SEQUENTIAL_MODE    - the main mode is sequential sampling
ADC_SINGLE_ENDED       - inputs are single-ended rather than differential
ADC_START_OPERATION    - the conversion should be started


Interrupts are not always used (it is possible to let the ADC free-run and just read at appropriate times) but the following interrupt types can be configured
ADC_END_OF_SCAN_INT             - interrupt when a scan has completed (one interrupt for ADC)
ADC_ZERO_CROSSING_INT_POSITIVE  - interrupt when the ADC input crosses zero in the positive direction (there is an interrupt per channel)
ADC_ZERO_CROSSING_INT_NEGATIVE  - interrupt when the ADC input crosses zero in the negative direction (there is an interrupt per channel)
ADC_LOW_LIMIT_INT               - interrupt when the ADC input falls below the low level trigger (there is an interrupt per channel)
ADC_SINGLE_SHOT_CROSSING_INT    - single shot mode for zero crossing channel interrupt (otherwise there are interrupt on every crossing)
ADC_HIGH_LIMIT_INT              - interrupt when the ADC input rises above the low level trigger (there is an interrupt per channel)
ADC_SINGLE_SHOT_TRIGGER_INT     - single shot mode for channel threshold interrupts (otherwise there are interrupt on every threshold crossing)
ADC_DISABLE_INTS                - disable interrupt(s)


Regards

Mark

86
NXPTM M522XX, KINETIS and i.MX RT / KINETIS Project Code
« on: April 27, 2012, 03:50:25 PM »
Hi All

This thread contains all versions of the release code - the latest release is at the top and previous releases are maintained in descending order.
Please check the patch list after the release notes of each version to get latest information on workarounds or bug-fixes.

OPENSOURCE VERSION:  - download freely and anonymously V1.4.11 from 5.2.2016 from the thread http://www.utasker.com/forum/index.php?topic=1721.msg7086#msg7086

Release 1.4.12.24/04/2017 Available as GIT branch "Version_24-04-2017" (SVN no longer updated)
==============================================================

What's new 24.04.2017 - Kinetis project:

New Graphical LCD Co-processor support
- FTDI FT800 support added, including FT800 emulation in the uTasker environment and non-blocking application interface which remains almost compatible with the FTDI reference examples. (Emulator may require VS 2012 compatibility - set platform tool set to v110 with VS 2012 installation present. Copy \WinSim\LCD\FT800\ft8xxemu.dll into the simulator's build directory in case it can't be found by the PC when the simulator is run).

USB-Host improvements
- USB-MSD host: Add USB_MSD_REMOVED event on memory stick removal.
-- utFAT handles USB_MSD_REMOVED when memory stick is removed

- USB host:
-- In host mode reset previous string reception length counter when reception completes with a zero length frame.
-- Use USB_DEVICE_TIMEOUT in host mode to repeat a get descriptor request.

- USB host driver:
-- Reset ulNextRxData0 in host mode when non-0 endpoint are re-used.
-- Add optional USB event logging for operation analysis.
-- Add setup frame response timeout and repetition in host mode.
-- Temporarily disable USB operation on host mode reset to ensure that state change flags can be reliably reset.

Easy configuration of a minimal test configuration
- Add "BLINKEY" configuration to allow a minimal configuration that blinks just an LED (and services the watchdog) with a single define.

Verified Teensy 3.6 operation
- Teeny 3.6 operation corrected and confirmed.

TCP/IP
- Add RFC 2217 (Telnet com port control option) mode to the Telnet module with application reference.

Various
- Increase UART support form maximum 6 to maximum 8.
- Add LTC (low power trusted cryptography) AES support.
- uTaskerConvert.exe updated to allow its use without requiring local DLLs to be present.
- ADC: Allow alternative DMA trigger sources.

- PWM: Add PWM_NO_OUTPUT option to allow PWM channel operation without connecting to an output.
-- Add DMA based frequency control option (eg. for stepper motors).
-- ADC_Timers.h adds options to trigger ADC conversion from TPMs and also to perform DMA based stepper motor type controls.

- Memory to memory DMA
-- Set the DMA_TCD_CITER_ELINK value earlier to protect initial part of code from interrupts.
-- Add optional alternative DMA channel for use by interrupts when the main one is in use.

-CAN
-- Set CAN clock before entering freeze mode but write further setting after moving to freeze mode.


KNOWN ISSUES:
- when using KDS and non-Cortex-M4 processors manually exclude the assembler files arm_bitreversal2.S and mmcau_aes_functions.s from the build target since they can not be assembled for the Cortex-M0+
- the same may be required in other IDEs where the assembly is cont controllable by the processor type selected)



Release 1.4.12 - 22.1.2017 - made available for registered users with valid support contract via private SVN and GIT
========================================================================

- Replaced all IIC references by I2C (file names, defines, variables)
- Added FRDM_KEAZN32Q64, FRDM_KEAZ64Q64 and FRDM_KEAZ128Q80
- Added TEENSY3.5 and TEENSY 3.6
- Added S32 Design Studio Projects
- Added I2C slave simulator
- Added CMSIS FFT support (with HW FPU support)
- Added ASE256 support (with HW CAU support)
- Flexible DMA trigger support for port pin interrupts, PITs, PWM.
- UART break support added
- DHCP server support
- Visual Studio 2015 Community Edition used as standard
- Blaze full support
- SVN and GIT repositories

In make_uTaskerV1.4_GNU_Kinetis m4 processor should be set up to correctly select FPU or non-FPU part!
All GCC based projects now share the linker scripts in "\Applications\uTaskerV1.4\GNU_Kinetis"

When working with VisualStudio post-build GCC make file, first edit the bat file to set your local GCC tool chain.
Eg.
SET PATH=%PATH%;D:\Freescale\KDS_v3\Toolchain\bin
in case KDS V3 is installed on drive D: in the directory Freescale.



Release 1.4.11 - 5.2.2016    http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.11.zip
============================================================
This is a consolidation of developer's versions (V1.4.8..V1.4.10) with most up-to-date support for registered users (free for non-commercial use) and licensed by professionals who value a fast and efficient development route to reliable, flexible, low-footprint solutions with intense support when and where needed.

- KBOOT serial mode option added to serial loader
- K02F, KE04, KE06, KEA128, KL03, KL43, K22,  K24, KL27, KV10 and KV31 support added
- Added Coffeebrain Capuccino-KL27 support
- Teensy LC support
- Low power support for WAIT, STOP, VLPS added, including unrestricted UART operation up to 57600 Baud in STOP based modes [FRDM-K64F] (higher Bauds possible but single reception byte errors can occur occasionally)
- KL TPM configurations to use OSCERCLK or MCGIRCLK instead of MCGPLLCLK/2 or MCGFLLCLK
- Low power timer Tick option (K and KL devices)
- RTC Tick option (KE devices)
- USB HID keyboard mode
- Multiple USB-CDC interfaces added, also in combination with other composite classes
- Composite USB device configurations added (mixtures of USB-MSD, USB-HID (mouse or keyboard) and (mutiple) USB-CDC)
- Updated extended file system to require the user to avoid using more that 61 blocks in the standard range and changed from "ZXXX" to "zXXX".
- Crystal-less USB option for K22, K24, KL26, K63, K64, K65 and K66 devices (USB_CRYSTAL_LESS) plus RUN_FROM_DEFAULT_CLOCK option to run from default FLL configuration (20..25MHz) without external clocks.
- True 2 stop bit mode added to UARTs which have no 2-stop bit support on their UARTs (interface tx needs to be used in interrupt driven mode and not DMA mode and option TRUE_UART_TX_2_STOPS enabled)
- Optional multiple FTP sessions supported (FTP_CONNECTIONS defines the quantity) 2 allows operation with FTP clients that require more than one for file transfers (such as Internet Explorer).
- K70 RGB support added
- Optional use of "section" programming operation for internal Flash programming
- KE IRQ support
- KE Keyboard interrupt support
- KE02 EEPROM support added
- LLWU low-leakage wakeup from LLS mode added
- Option for locating fixed interrupt vectors in flash
- USB IN/OUT endpoints can share a single Kinetis USB controller endpoint
- utFAT in SPI Flash (AT45DBxxx with 512/528 byte page size) and in internal flash
- Time keeper module added which controls RTC, time-zones, daylight saving, time conversions, display and SNTP operation (based on simple second counter or RTC)
- RTC alarm and wakeup from low leakage modes
- Software RTC (with time maintained across resets) for devices without in-built RTC
- TELNET client
- Updated SNMPv1/V2c for enterprise MIB operation
- Green Hills project added
- Software FIFO (queue) driver added
- Single/Double SC16IS7xx SPI extension for additional 2/4 UARTs added.
- Integrated FreeMaster USB/serial support with additional write support in internal and/or external SPI Flash (provisional implementation)
- Touchscreen mouse interface added with press, release and move events
- Kinetis peripherals removed from kinetis.c to their own individual include files
- IAR projects udated to IAR7
- uVision projects udated to uVision5
- Microchip ENC624J600 driver allowing dual-port Ethernet operation on parts with Ethernet or Ethernet extension for parts without
- Spansion S25FL SPI flash driver added with automatic suspend/resume to interrupt sector erasure
- Modbus ASCII possible on multiple USB-CDC interfaces, together with command line menu and USB-UART bridges on further CDCs.
- Optional out-of-order TCP frame input buffer (USE_OUT_OF_ORDER_TCP_RX_BUFFER)
- Composite USB-MSD and KBOOT serial loader configuration
- USB-MSD loader full MAC OSX and Windows 8.1 compatibility
- Optional AN2295 Freescale Developer's Serial Bootloader compatibility mode added to the serial loader
- Nordic-Semi nRF24201+ 2.4GHz application radio support
- HID raw USB device support added
- Winbond W25Q SPI flash driver added
- USB host MSD boot loader (with optional device mode at the same time)
- utFAT on both SD card and memory stick (multiple disks)
- New board/device support: KW21, KW24
- I2C slave support
- Double-buffered I2C operation (master and slave compatibility with KLx7 for example)
- tinyK20 target
- rcARM target
- USB-MSD Host/Device loader using new USB-OTG driver (allows host [memory stick] and device loader mode at the same time, with automatic detection of the mode to use). See the updated user's guide: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF
- Emulated FAT - see http://www.utasker.com/docs/uTasker/uTaskerEmulatedFAT.pdf
- Touch Slider for KL boards
- Display worst-case stack use depth
- USB device driver replaced with USB OTG driver
- Memory Swap support (available in several Kinetis parts) - with UART S-REC and USB-MSD operation: see http://www.utasker.com/forum/index.php?topic=1909.0
- Memory stick (USB-host) support (FAT), also in parallel with SD card operation (SD card is disk D: and Memory stick is disk E:)
- Serial loader supports Intel Hex and/or SREC
- USB-CDC SREC/iHex mode in serial loader
- USB-MSD memory stick loader supports deleting the file after successful loading
- USB-MSD host supports memory sticks that share bulk endpoints to IN and OUT
- Memory stick disk simulation added (equivalent to SD card simulator) - saved as MEMSTICKx.bin (where there are multiple files for multiple LUNs (x); x = 0 if single LUN)
- Faster disk simulation method enabled (thanks to Steve S.)
- USB-CDC host mode for connection to USB-CDC devices for bi-directional communication link (virtual COM between two boards)
- DHCP client supports resolving on multiple networks and interfaces
- FRDM-K82F support
- DAC and PWM sigal generator from buffer using DMA
- Buffer<->peripheral support integrated in DMA driver
- IP fragmentation/de-fragmentation option
- Integrated EzPort cloner
- USB Audio device class
- RNDIS support added (USB-Ethernet adapter which can operate together with the TCP/IP stack without an Ethernet interface)
- FreeLON board support
- Blaze support

When using USB-MSD please add the following lines to the routine fnConfigureApplicationEndpoints() in usb_application.c:
At line number 3817:

    #if defined USE_USB_MSD
        #if defined USB_HS_INTERFACE
    tInterfaceParameters.usEndpointSize = 512;                           // endpoint queue size
        #else
    tInterfaceParameters.usEndpointSize = 64;                            // endpoint queue size (2 buffers of this size will be created for reception)
        #endif


which sets the correct endpoint size - it had got lost in this configuration and so was random.



Release 1.4.7 - 8.7.2014 - download the latest version from the thread http://www.utasker.com/forum/index.php?topic=1721.msg6697#msg6697
=============================================================================================
- LPTMR support added
- Optimised DMA based uMemset()/uMemcpy()/uReverseMemcpy() to utilise widest transfer sizes possible (aligned buffer copies can be 7.5x faster than conventional byte based memcpy())
- PWM_LED_CONTROL option added to allow RGB colour control (available on various Freescale boards) based on accelerometer readings
- USB clock configuration based on PLL1 added (mainly for use by 150MHz parts at full speed)
- Add operating details (memory sizes, bus and flash clock speeds and UART settings) to simulator status bar
- Added KE02 serial boot loader (initial KE family support)
- Added KE02 application (UART, I2C FTM with PWMs, SPI with SD-card)

This version has the CodeWarrior set as default (Atollic and KDS settings can be loaded according to details in the readme.txt in the highest directory of the project).
Serial loader and V1.4 application are configured for KE02 as default; set the Kinetis part as required.

Note that the Ethernet interface is disabled by default so be sure to enable it if needed (eg. when following the Ethernet tutorial!):
In config.h:
//#define ETH_INTERFACE                                                // enable Ethernet interface driver



IMPORTANT correction in utFAT [mass_storage.c]:
In the function
static int _utOpenFile(const CHAR *ptrFilePath, UTFILE *ptr_utFile, unsigned long ulAccessMode)
add
        uMemcpy(&openBlock.DirectoryEndLocation, &ptr_utFile->ptr_utDirObject->public_disk_location, sizeof(openBlock.DirectoryEndLocation)); // {1}
after the line
openBlock.ptr_utDisk = &utDisks[ptr_utFile->ptr_utDirObject->ucDrive];
at line number 4616.

When using the Rowley Crossworks or Keil projects the (new) files stack\igmp.c and Applications\uTaskerV1.4\snmp_mib_handlers.c need to be added to the V1.4 project if either IGMP or SNMP are enabled.

In uMemcpy() in kinetis.c (when based on DMA) move

            while (Size--) {                                             // {87} complete any remaining bytes
                *ptr++ = *buffer++;
            }

from before
            while ((ptrDMA->DMA_DSR_BCR & DMA_DSR_BCR_DONE) == 0) { fnSimulateDMA(DMA_MEMCPY_CHANNEL); } // wait until completed
to after it. This will ensure that buffer shifts base on DMA can't have the last byte(s) corrupted due to writing before the DMA has used the initial values.

----------------------------------------------------------------------------------------------------------------------------------
For Keil users:
Rename (in kinetis.c)
__attribute__((section("F_INIT"))) const KINETIS_FLASH_CONFIGURATION flash_config
to
__attribute__((section("F_INIT"))) const KINETIS_FLASH_CONFIGURATION __flash_config
to match the linker script's keep setting.

When using Keil uVision for KE or KL projects the following conditional assembler code is needed in Kinetis_asm.s

    EXPORT start_application
start_application
        IF :DEF:KINETIS_KL
    ldr r1, [r0,#0]                                                      ; get the stack pointer value from the program's reset vector   
    mov sp, r1                                                           ; copy the value to the stack pointer
    ldr r0, [r0,#4]                                                      ; get the program counter value from the program's reset vector
    blx r0                                                                  ; jump to the start address
        ELIF :DEF:KINETIS_KE
    ldr r1, [r0,#0]                                                      ; get the stack pointer value from the program's reset vector
    mov sp, r1                                                           ; copy the value to the stack pointer
    ldr r0, [r0,#4]                                                      ; get the program counter value from the program's reset vector
    blx r0                                                                  ; jump to the start address
        ELSE
    ldr sp, [r0,#0]                                                      ; load the stack pointer value from the program's reset vector
    ldr pc, [r0,#4]                                                      ; load the program counter value from the program's reset vector to cause operation to continue from there
        ENDIF   
    ALIGN

When using ETH_INTERFACE: the files stack\igmp.c and snmp.c may need to be added to the TCP/IP group in the uVision project. Also snmp_mib_handlers.c to the Source Files group.

Set the defines KINETIS_KL or KINETIS_KE (when using these devices) in the asm define setup.
----------------------------------------------------------------------------------------------------------------------------------




Release 1.4.6 - 12.6.2014 - http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.6.zip
============================================================
- Add KL DMA support for memcpy() and memset()
- Add KL DMA support for UART transmission (UARTs 0, 1 and 2)
- Add KL port interrupt support
- KL02, KL04 and KL05 I2C and TPM pin configurations added
- FlexNVM support added as data memory
- K64F DMA and ADC setup added
- Interrupt driven accelerometer setups added
- Memory debug interface improved and extended with storage display and modification capabilities
- CooCox CoIDE projects added
- Crossbar configuration added for optimised DMA priority control
- Encrypted SD card loader support
- KBOOT 1.0.1 HID mode added to serial loader

Note that the Eclipe setup is for KDS so replace the Eclipse setup files (as explained in the V1.4.5 release notes below) when working with CW10.x or Atollic

In case of compiler errors in the routine utReadFile() when building mass_storage.c  place the close bracket at line 3757 of mass_storage.c by the following
    #if defined UTFAT_FILE_CACHE_POOL && (UTFAT_FILE_CACHE_POOL > 0)
        }
    #endif



Release 1.4.5 - 04.5.2014 - http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.5.zip
============================================================
- Add KL RTC support based on LPO 1kHz or external clock (plus time display in KL46 SLCDs) [see SUPPORT_RTC and SUPPORT_SLCD]
- Add KL PIT support (single-shot and periodic interrupts) [see SUPPORT_PITS and TEST_PIT in ADC_Timers.h]
- Add KL TPM support (PWM, single-shot and period interrupts) [see SUPPORT_TIMER and SUPPORT_PWM_MODULE and TEST_TIMER and TEST_PWM in ADC_Timers.h]
- I2C lockup detection and recovery added to I2C driver (if a reset took place when a slave device was in the process of returning an acknowledgment the I2C bus can get stuck in a bus busy state - this is detected and clocks generated on the SCL line to free the slave and allow normal operation without requiring a power cycle)
- HID loader support for Freescale PC program "HIDBootloader.exe" from the application note AN4764 "Freescale HID Bootloader"
- FRDM-K64F configuration changes to match some K64 peripherals and board requirements

- KDS (Kinetis Design Studio) support added.
IMPORTANT: This release is configured by default for the FRDM-K64F and so can be imported directly into KDS. To work with CodeWarrior copy the Eclipse project files from \Applications\uTaskerV1.4\KinetisCodeWarrior\ProjectSettings to the project root directory after removing the KDS ones from that location; switch between CW10.x, KDS and Atollic using the same method - there is a corresponding set of Eclipse project files in:
- \Applications\uTaskerV1.4\KinetisDesignStudio\Project_Settings
- \Applications\uTaskerV1.4\KinetisCodeWarrior\ProjectSettings
- \Applications\uTaskerV1.4\KinetisAtollic\Project_Settings
It is recommended to keep a backup of these settings when switching between IDEs in case one environment corrupts the setting of others.

Get latest news about KDS and help in case of problems at https://community.freescale.com/community/kinetis-design-studio


When using the USB-MSD loader in FAT12 mode (standard) the following #if def needs to be inverted (changed from #if !defined UTFAT16 to #if defined UTFAT16) so that read-back operates correctly:
- usb_loader.c line 1781 just after the line with if (iSoftwareState == SW_AVAILABLE) {

When using the IAR project the new files stack\igmp.c and Applications\uTaskerV1.4\snmp_mib_handlers.c need to be added to the IAR project.

When using the K61, K70 or K60F120 processors increase the size of RAM reserved for their interrupt vectors in the linker script used (eg. K_1M_128.ld) to 0x1f0
eg. in IAR linker script
define symbol __ICFEDIT_region_RAM_start__ = 0x1fff01b0;
should be change to
define symbol __ICFEDIT_region_RAM_start__ = 0x1fff01f0;






Release 1.4.4 - 16.4.2014 - http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.4.zip
============================================================
- Initial KL support added (FRDM_KL02Z, FRDM_KL05Z, FRDM_KL25Z, FRDM_KL26Z, TWR_KL25Z48M, TWR_KL46Z48M)
- Additional board configurations added (FRDM_K20D50M, TWR_K20D72M, TEENSY_3_1, TWR_K21D50M, TWR_K21F120M, TWR_K40D100M, FRDM-K64F, TWR_K64F120M)
- Flexible serial loader configurations for all board configurations included
- Atollic project included
- CodeWarrior 10.5 project reconfigured for GCC compiler so that KL devices can be used
- USB host mode Beta
- LED simulation configuration has an additional control to define whether the LED is in the '0' or '1' state should the driving pin be configured as an input.
- Port details displayed when mouse hovers over connected inputs/switches on board
- Multi-colour LED colour mixture support in the simulator
- SNMPV1 and SNMPV2c with multiple manager support, MIB table according to rfc 1213 and user entry capability
- IGMP V1/V2 support on multiple networks and interfaces
- 3-axis accelerometers (MMA8451Q and MMA7660F)
- 6-axis sensor (accelerometer/magnetometer FXOS8700CQ)
- Wave file recorder added to DMA controlled ADC streaming
- Multiple network IP/MACs displayed in simulator (test two IP addresses with "#defined IP_NETWORK_COUNT 2")
- Standalone web server software upload support added to serial loader project
- Single shot and periodic interrupts option using FlexTimer

IGMP is enabled as default. The IP counters are extended when enabled and they don't match with the counters on the statistics page of the web server. Either disable IGMP so that they do match or else use the following HTML file in place of 8Stats.htm - http://www.uTasker.com/software/V1.4/8StatsIGMP.htm

When using the SREC boot loader add the following line to the end of the task intialisation:
iAppState = STATE_ACTIVE;
This line got lost when Ethernet code was added.

When using the VisualStudio uTaskerV1.4 project the new file igmp.c needs to be added to the project when Ethernet and IGMP are enabled.

When using SDCARD_SUPPORT in the serial loader add the following to SDLoader.c
#undef T_GO_TO_APP
before the line
#define T_GO_TO_APP                1
to remove a warning about the value being redefined.





Release 1.4.3 - 2.01.2014 http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.3.zip
============================================================
- Added general purpose routine uReverseMemcpy() [same as memcpy but in reverse order - useful when right-shifting buffers] - also using DMA as option
- Serial Loader supports SREC, USB-MSD and SD-card at the same time
- utFATV2.0 - Beta
- ADC -> DAC buffered mode based on PDB/DMA with digital delay line demonstration

In Kinetis.c fnGetRndHW() when RNGA is used the simulator needs the following lines
    while (!(RNG_SR & RNG_SR_OREG_LVL)) {
        #if defined _WINDOWS
        RNG_SR |= RNG_SR_OREG_LVL;
        #endif

    }
        #if defined _WINDOWS
    RNG_SR &= ~RNG_SR_OREG_LVL;
        #endif


This version includes a Beta version of utFAT2.0 and the following change is required to ensure that deleting LFN directories can't cause the corruption of a random sector on the disk:
In static int _utOpenFile(const CHAR *ptrFilePath, UTFILE *ptr_utFile, unsigned long ulAccessMode)
...
    else if (iReturn == UTFAT_SUCCESS) {                                 // a directory was matched
        uMemcpy(&ptr_utFile->private_disk_location, &ptr_utFile->ptr_utDirObject->public_disk_location, sizeof(ptr_utFile->ptr_utDirObject->public_disk_location)); // copy the referenced directory details
        ptr_utFile->ulFileMode = (UTFAT_FILE_IS_DIR | ulAccessMode);     // {103a} mark that the entry is not a file but a directory
        ptr_utFile->ucDrive = ptr_utFile->ptr_utDirObject->ucDrive;
#if defined UTFAT_LFN_READ && ((defined UTFAT_LFN_DELETE || defined UTFAT_LFN_WRITE) || defined UTFAT_EXPERT_FUNCTIONS)
        uMemcpy(&ptr_utFile->lfn_file_location, &openBlock.lfn_file_location, sizeof(ptr_utFile->lfn_file_location)); // save the start of a LFN entry so that its length and location is known
#endif

    }
    return iReturn;
}

To ensure that new LFN are conform there is an error in fnInsertLFN_name() that needs to be corrected:
            // Fall through intentional
            //
        case -1:
            ptrLongFileEntry = (LFN_ENTRY_STRUCTURE_FAT32 *)ptrDirectorEntry;
            uMemset(ptrLongFileEntry, 0x00, sizeof(LFN_ENTRY_STRUCTURE_FAT32));   // ensure initially zeroed



When using the RTC ensure that the data calculated from the seconds count value is correct by modifying two lines in static void fnConvertSecondsTime(unsigned long ulSecondsTime, int iSet) in kinetis.c:
iLeapYear = LEAP_YEAR(usYear); this line should be changed to
iLeapYear = LEAP_YEAR(_usYear); (note the underscore in the variable name)

and
_ucDayOfWeek = fnIncDayOfWeek(_ucDayOfWeek, monthDays[ucMonthOfYear]); thsi line should be changed to
_ucDayOfWeek = fnIncDayOfWeek(_ucDayOfWeek, monthDays[_ucMonthOfYear]); (note the underscore in the variable name)

When working with the simulator, the following changes in extern void fnInitInternalRTC(char *argv[]) will ensure that the seconds counter is correctly synchronised to the PC's time
if ((RTC_MONTH > 2) || (RTC_DOM > 28)) { should be change to
if ((RTC_MONTH > 2) && (RTC_DOM > 28)) {[//tt] - note the &&

and
ulKinetisTime += monthDays[RTC_MONTH ]; should be changed to
ulKinetisTime += monthDays[RTC_MONTH - 1]; - note the -1



If is recommended to make the following two pointers in the routine fnEnterInterrupt() in kinetis.c volatile:

// Function used to enter processor interrupts
//
extern void fnEnterInterrupt(int iInterruptID, unsigned char ucPriority, void (*InterruptFunc)(void)) // {55}
{
    volatile unsigned long *ptrIntSet = IRQ0_31_SER_ADD;
    volatile unsigned char *ptrPriority = IRQ0_3_PRIORITY_REGISTER_ADD;


This avoids the possibility of compilers that in-line the function and perform agressive optimisation of register accesses from losing an interrupt mask setting when multiple fnEnterInterrupt() are called in a row.








Release 1.4.2 - 9.09.2013 http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.2.zip
============================================================
- Ethernet Boot Loader added to Full Licensed Project.
- TCP/IP stack adapted for multiple interface and multiple network support - see http://www.utasker.com/forum/index.php?topic=1748.0 for details about application compatibility.
- FTP client only commands ASCII or Binary modes when it is not known in which mode it is presently in and a change is needed.
- FTP client Listing and Getting requires both the server's success response and the data connection to be closed before terminating and informing of success.
- FTP client now supports operation with servers over IPv6.
- Free running UART DMA reception mode
- Reset TCP connections when SYN (without ACK) received on connected TCP port.
- Devices that support EMAC little-endian mode of operation use this automatically (see ETHER_DBSWP bit).
- Optional polling of SD card to detect removal during operation (by reading a sector), by polling card detect switch, or based on card detect switch interrupt (see http://www.utasker.com/forum/index.php?topic=1747.msg6270#msg6270).
- Program once area supported (SUPPORT_PROGRAM_ONCE) and MAC address can optionally be stored there (MAC_FROM_USER_REG) - when this is enabled the MAC address is only saved to the OTP area when saved using the MAC command via the command line index. This can never be deleted!!
- EmCraft K70F120 and K61F150 configurations added.
- uTaskerCombine has new optional srec output as well as srec/ihex offset parameter
- uTaskerV1.4 project uses a new include file for debug.c called debug_hal.h. This includes some hardware specific functions allowing easier management of processor and hardware target types
- Managed read and managed write support added
- Add PHY SMI mode and KSZ8863 support including tail-tagging mode
- PHY_POLL_LINK support for designs without PHY interrupt line
- DHCP_HOST_NAME option for DHCP
- Respect peer's MSS when sending HTTP frames
- TCP polling timer enabled only when required by a socket
- Optional high resolution TCP polling timer resolution (T_TCP_PERIOD)
- Don't reply to NetBios requests when DHCP is still resolving
- _EXTENDED_HTTP_MIME_CONTENT_SUPPORT activates HTTP content-type to be added to HTTP header
- Magic Ethernet frame reception support added
"The define _MAGIC_RESET_FRAME enables magic frame checking support.
Initially no checking is done until it is enabled by calling fnEnableMagicFrames(1).
It can later be disabled if require by calling fnEnableMagicFrames(0).
When active, each received Ethernet frame is checked directly in the receive interrupt routine for Ethernet payloads of 93 bytes in length.
The definition of _MAGIC_RESET_FRAME determines the magic frame pattern that is expected (repeated 16 bit value) - for example
#define _MAGIC_RESET_FRAME        0x1234
A magic frame must then contain this value repeated 24 times in the first 60 bytes of the payload (following the two Ethernet II MAC addresses) in order to be recognised.
The 61st byte in the frame can then be used as code to trigger an action. The value 0x01 causes the board to reset and place a code in the boot loader mail box so that the boot loader can recognise that the board was reset via use of a magic frame. The boot loader will normally remain in the boot loader mode (possibly for a limited period of time) to allow software updates to be accepted.
The final 32 bytes of the frame are undefined and can have any pattern. The user can use these as optional information bytes if required (for example, there is adequate space to pass 2 IPv6 addresses for special configuration purposes, etc.)
The handling interface has to be supplied by the user (eg. in application.c) as follows:
extern void fnMagicFrame(unsigned char ucType, unsigned char usOptionalDate[32]) {}"
- Add ELZET80_DEVICE_DISCOVERY
- ELZET80 Network-Utility for discovery and commanded reset to boot loader mode
- Add IP multicast rx and tx
- MEMORY_DEBUGGER adds a memory debugger (memory display, memory modify and memory fill) to the command line interface
- DAC interface added for non-buffered software mode
- SDRAM with secondary uMalloc() area in external memory
- PARAMETER_NO_ALIGNMENT option to improve parameter block efficiency when byte writes are not needed (the application must write aligned blocks)
- High-speed USB device support for Kinetis devices with this controller [#define USB_HS_INTERFACE]
- KBED configurations added (KBED and NETK60)
- ST7565S LCD support added via flex bus or SPI
- HS USB MSD boot loader mode
- TWR-SER2 support (Ethernet/HS USB)






Release 1.4.1 - 27.04.2012 http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.1.zip
============================================================

- Long File Name delete added using define UTFAT_LFN_DELETE
- Access to SD card (utFAT) controllable individually for HTTP and FTP; root directories can be changed during operation.
- SD card visualisation in simulator (preliminary)
- Optional polling of SD card to detect removal during operation
- Corrected UDP and IPV6 checksum insertion when offloading enabled
- Added TWR-K70F120M support
- Added TWR-K53N512 support
- Added TWR-K20N50M support
- K20 (32..144 pin parts included in simulator)
- Advanced IPv6 support with link-local and global IPv6 addresses. TCP based services (such as HTTP and FTP) are operational on link-local IPv6 address and global IPv6 address as well as IPv4 (dual-stack).
- Global IPv6 address can be optionally tunnelled in 6in4 (tunnelling IP address is configurable) when native IPv6 is not possible.
- Configurable 6in4 relay agent to expose multiple IPv6 devices behind simple IPv4 routers.
- Start web page shows IPv4 or IPv6 source address depending on connection.
- Flash programming adaptation to respect FPU type Flash with phrase write rather than word write (corresponding adjustment to uParameterSystem interface and 4k Flash sector size)
- UART DMA support on transmission (up to 6 UARTs) and reception (half or full buffer notifications) - simulation of DMA operation integrated
- Configurable DMA channels and priorities
- New I2C simulation devices (PCA9539, PCF2129A)
- PWM support (FTM)
- Ethernet bridging support
- Buzzer output simulation (eg. for use with keypad)
- Frontpanel simulation support with connection of keys and LEDs to ports - including external I2C port expanders
- User button simulatins in frontpanel and configurable frontpanel image
- x,y coordinates shown when mouse is on keypad/front panel
- Touch Sense support including simulation
- Improved CW10.2 projects for simple building with bootloader support
- Task performance monitoring configuration
- ADC support including (preliminary) simulation support
- define HTTP_POST_DEFINES_PAGE allows user file to be served as specified by the file name in a POST, rather than special uFile name
- define HTTP_SET_USERFILE_START_PAGE allow a specific user file to act as HTTP default start side
- define HTTP_SERVE_ONLY_USER_FILES allows serving exclusively user files - if a defined user file is not found display 404 error rather than a uFileSystem equivalent

This version (specifically IPv4/IPv6 dual-stack) can be seen in operation at: http://youtu.be/BMPXhtoUeJo

The following modification is required when simulating internal flash on devices without FPU (using long word programming rather than phrase programming).
In kinetis.c, routine fnFlashNow()


    #if defined KINETIS_K_FPU                                            // {10} write second long word
            ptr_ulWord++;
            FTFL_FCCOB8 = (unsigned char)(*ptr_ulWord >> 24);            // enter the second long word to be programmed
            FTFL_FCCOB9 = (unsigned char)(*ptr_ulWord >> 16);
            FTFL_FCCOBA = (unsigned char)(*ptr_ulWord >> 8 );
            FTFL_FCCOBB = (unsigned char)(*ptr_ulWord);
    #endif
    #ifdef _WINDOWS
            *(unsigned long *)fnGetFlashAdd((unsigned char *)(ptrWord + 1)) = *ptr_ulWord;;
    #endif

This needs to be modified to only write the simulated flash when the define KINETIS_K_FPU is true:

    #if defined KINETIS_K_FPU                                            // {10} write second long word
            ptr_ulWord++;
            FTFL_FCCOB8 = (unsigned char)(*ptr_ulWord >> 24);            // enter the second long word to be programmed
            FTFL_FCCOB9 = (unsigned char)(*ptr_ulWord >> 16);
            FTFL_FCCOBA = (unsigned char)(*ptr_ulWord >> 8 );
            FTFL_FCCOBB = (unsigned char)(*ptr_ulWord);
        #ifdef _WINDOWS
            *(unsigned long *)fnGetFlashAdd((unsigned char *)(ptrWord + 1)) = *ptr_ulWord;
        #endif

    #endif



It has been found that some builds of CW10.2 fail with a linking error missing symbol called __SP_INIT.
To solve, add the symbol to the linker script file being used by the project (eg. \Applications\uTaskerV1.4\KinetisCodeWarrior\Project_Settings\Linker_Files MK60N512VMD100_flash.lcf):

For example, at the end:

} >> sram
__text_load_start__ = ___DATA_ROM;
__text_start__ = __text_load_start__;
__text_end__ = __text_load_start__;
__data_start__ = ___DATA_RAM;
__data_load_start__ = __text_load_start__;
__data_end__ = ___DATA_END;
__bss_start__ = __START_BSS;
__bss_end__= ___BSS_END;
__heap_end__ = __bss_end__;
__SP_INIT   = __bss_end__;                             <---- dummy symbol to satisfy the linker
}


The value given to the symbol is not important since it is not used.
The potential linker problem is also discussed here: https://community.freescale.com/message/113310#113310





Release 1.4.0 - 22.02.2012 http://www.uTasker.com/software/V1.4/uTaskerKinetisV1.4.0.zip
============================================================
- Additional queue protection added to allow nested writes and nested reads from same queue in interrupts
- New target for TWR-K60F120M (configuration allows high speed FPU based devices to be used)
- SD card recognition in SDHC mode corrected
- The size of SD card larger than 4G is now displayed in kBytes to stop byte length overflow in 32 bit format
- SD card simulator can be configured to simulate 1G, 2G, 4G, 8G and 16G SD cards, as well as no SD card inserted
- Rowely Crosswork projects reworked to include RAM based debugging as well as Flash based

Note that the project is configured for the KWIKSTIK - change the target in config.h to suit and adjust any settings in the IDE used to match.

If using USB application on the KWIKSTIK the following change should be made in fnConfigureUSB() in usb_application.c to allow it to use the internal clock for the USB controller:
#if defined TWR_K60N512 || defined TWR_K60F120M || defined KWIKSTIK
    tInterfaceParameters.ucClockSource = INTERNAL_USB_CLOCK;             // use system clock and dividers
#else
    tInterfaceParameters.ucClockSource = EXTERNAL_USB_CLOCK;             // use 48MHz crystal directly as USB clock (recommended for lowest jitter)
#endif








*****************************************************************************************
Please note that the SW packages are protected by the corresponding project password.
To register and receive the password, simple fill out the form: http://www.utasker.com/Licensing/request.html
Don't be afraid - the project is free and supported for everyone; just for commerical use a small fee for premium
support is requested (donation after making their first million profit also welcomed..;-)
*****************************************************************************************

87
IPv6 / New IPv6 board added
« on: April 02, 2012, 12:08:19 AM »
Hi All

I decided to add a new board due to the fact that additional IPv6 support has been added to the project and will be included in new releases shortly.

It is well known that the last IPv4 addresses have been exhausted at IANA. That is, the final blocks have been allocated to the regional administators and these are being allocated in the individual regions until they finally run out.

The importance of IPv6 is increasing and will probably become an even bigger theme once applications for new global IPv4 addresses actually start getting turned down.

In preparation for this there has been a recent push concerning the IPv6 suppport in the uTasker project. There was some test support for ICMPv6 in a local network which layed the foundations but this has now been extended to TCP services operating over IPv6 or tunnelled in 6in4 IPv4 protocol, which is expected to be a predominant method during a long transition phase until providers have updated their networks to support raw IPv6 operation right to the average user.

This dual-stack approach allows servers such as web servers, Telnet, FTP etc. to be able to operate over IPv4 and IPv6. The higher software layers (andn applications) are almost fully compatible and don't usually need to know which transport type is being used, so adding IPv6 capability to projects is only a matter of activating the support and configuring some IPv6 addresses.

The IPv6 User's Guide has been released, detailing all up-to-date information, here: http://www.utasker.com/docs/uTasker/uTaskerIPV6.PDF

I'll also be updating the on-line demo at http://demo.utasker.com shortly to include this operation with links to it via IPv6 global addresses. By following the user's guide it should be possible for anyone to then contact this device (and others devices which may be configured behind the same IPv4 gateway) to get an idea of the capabilities.

I look forward to specific discussions about IPv6 operation in the project and further developments to enable advantage to be taken of IPv6 capabilities in real projects.

Regards

Mark


88
utFAT / utFAT - next generation
« on: March 05, 2012, 01:43:21 AM »
Hi All

I wanted to, first of all, point out that there is an updated version of the utFAT user's manual:
http://www.utasker.com/docs/uTasker/uTasker_utFAT.PDF

This now contains some details about FAT16 as well as FAT32 with an improved section concerning FAT its operating details.
More importantly, however, it now has a complete and up-to-date User Interface description.

This update is important since next steps in the project development are being planned. The reason is that the present project state has reached a certain maturity and is now being used in various project and the demand for its functionality is becoming more important in various new application developments in the planning phase. The focuses of the next stage of development are:
- improved SD card insertion/removal management
- improved application control of utFAT and uFileSystem
- LFN write support

The last of the features on this list represents the major development part, and the major additional documentation task.

It is to be noted that the fact that the present version doesn't support LFN writes has been removed from the document (attempts to write simply cut the file name to its 8:3 length limit and so is quite obvious and doesn't cause any corruption) since thsi is now (hopefully) a temporary limitation which will be fully discussed shorrly in the new LFN chapter.

With FAT16 and FAT32 and full LFN support for read and write should make it a very complete solution, so I am lookig forward to the outcome!!

Regards

Mark

89
µTasker general / CAN and CAN Simulator
« on: December 31, 2011, 11:16:12 PM »
Hi All

As closing development for 2011 I have just managed to complete the Dual FlexCAN driver for the Kinetis project. There has been a CAN driver in the Coldfire project for a long time (single CAN interface) and this additional has also allowed the integration of a new standard CAN simulation technique using a CAN bus analyser called the KOMODOTM CAN DUO from TOTAL PHASE http://www.totalphase.com/products/komodo_canduo/

This is described in the revised CAN driver documentation: http://www.utasker.com/docs/uTasker/uTaskerCAN.PDF
and demonstrated in the video guide: http://youtu.be/Ha8cv_XEvco

Regards

Mark


90
Hi All

Freescale has now released their K70 - http://forums.freescale.com/t5/Kinetis-ARM-Cortex-M4/Freescale-now-offering-single-chip-graphics-LCD-Kinetis/td-p/91499

It has an integrated LCD controller and FPU and operates at up to 150MHz. Engineering samples are available today and also a board for the Tower Kit is orderable. The graphic LCD module that will go with the tower kit especially for the K70 should be available in January 2012 (the present TFT board has an internal controller and so connects via the FlexBus interface rather than the LCD controller).

It looks as though also ATOLLIC will be supporting the Kinetis range of devices so I will have a go at adding the K70 to the project and an Atollic project to the package. [I'll wait for the LCD board to be available before ordering the new Tower board though]

Regards

Mark

Pages: 1 ... 4 5 [6] 7 8 ... 19