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 - mhoneywill

Pages: 1 [2] 3
16
Luminary Micro TM LM3SXXXX / Fixing an IIC lockup with SDA held low
« on: August 05, 2010, 03:15:18 PM »
Hi Mark,

We've it a problem where a noise spike can cause the IIC bus to lockup the condition is described here on a TI website here http://processors.wiki.ti.com/index.php/I2C_Tips

The problem is described below

A problematic scenario can arise if the processor/I2C module gets reset while it is in the middle of mastering a transfer. In this scenario the external slave might be holding SDA low to transmit a 0 (or ACK). In this case it will not release SDA until it gets another falling edge on SCL. Even in this case it's not until it tries to transmit a '1' that it will actually release SDA after seeing SCL fall. The end result is that the bus will hang. If the I2C tries to initiate a new transfer it will hit an "arbitration lost" condition because SDA won't match the address it's sending. There are a couple ways to recover from this scenario.

Option 1: For devices that mux the SCL/SDA pins with GPIO, the easiest thing is to configure the pins for GPIO operation and toggle SCL until the slave releases SDA. At this point you should be able to resume normal operation.

Option 2: Many devices don't mux SCL/SDA with GPIO since the I2C I/O cells are often special open drain cells. A workaround has been reported to work even on these devices. By configuring the I2C for "free data format" and then reading a byte the I2C will immediately start sending clocks to input data (rather than trying to send an address). This can be used to free up the bus.


I.m not sure what "free data format" is, so it seems like the solution is to trap the condition and to switch the SCL line back to GPIO then toggle it a nuber of times (say 16) to get out of this state. Then restart the IIC bus. This poses a number of questions

1. Looking at the Port configration Marcro's it looks like they are not configured for selecting a GPIO function after they have been used for a pheripheral. (They don't access the GPIOAFSEL_x registers) I suggest adding GPIOAFSEL_##ref &= ~(pins); as shown below.

2. Looking at the code below, why is the statement SRCR2 &= ~CGC_GPIO##ref; repeated? is this a typo or for timing reasons.

3. If I reinitialise the IIC using fnConfigIIC can you forsee any problems?

4. How do I detect the problem in the first pace, as the IIC module does not report errors (I guess I could try reading a register which I know to ge a fixed value and if I see 0xff then assume an error)

Code: [Select]
// Port macros
//
// Configure pins as output, including enabling power and digital use. eg. _CONFIG_PORT_OUTPUT(A, PORTA_BIT0);
//
#define _CONFIG_PORT_OUTPUT(ref, pins)  RCGC2 |= CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; \
GPIOAFSEL_##ref &= ~(pins); GPIODEN_##ref |= (pins); GPIODIR_##ref |= (pins); _SIM_PORT()
// Configure pins as input, including enabling power and digital use. eg. _CONFIG_PORT_INPUT(B, PORTB_BIT2);
//
#define _CONFIG_PORT_INPUT(ref, pins)   RCGC2 |= CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; \
GPIOAFSEL_##ref &= ~(pins); GPIODEN_##ref |= (pins); GPIODIR_##ref &= ~(pins); _SIM_PORT()

// Configure Pullups and Pulldowns
#define _CONFIG_PORT_PULLUP(ref, pins)   GPIOPUR_##ref |= (pins); _SIM_PORT()
#define _CONFIG_PORT_PULLDN(ref, pins)   GPIOPDR_##ref |= (pins); _SIM_PORT()
#define _CONFIG_PORT_INPUT_PULLUP(ref, pins)   RCGC2 |= CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; \
GPIOAFSEL_##ref &= ~(pins); GPIODEN_##ref |= (pins); \
GPIODIR_##ref &= ~(pins); GPIOPUR_##ref |= (pins); _SIM_PORT()
#define _CONFIG_PORT_INPUT_PULLDN(ref, pins)   RCGC2 |= CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; SRCR2 &= ~CGC_GPIO##ref; \
GPIOAFSEL_##ref &= ~(pins); GPIODEN_##ref |= (pins); \
GPIODIR_##ref &= ~(pins); GPIOPDR_##ref |= (pins); _SIM_PORT()

17
MODBUS / Modbus Timeout Error
« on: July 29, 2010, 03:56:10 PM »
Hi Mark,

Just thought I'd let you know about a "feature" I'd found in the modbus module, and thought you might want to mention in the Modbus manual.

I have a modbus system running and was trying to tighten up the timeout delay because my targets reply very quickly. I accidentally set the modbus timeout value in the cMODBUS_default in modbis_app.c to the same value as the uTasker TICK_RESOLUTION. This was then causing random suprious comms timeouts, which took some while to trace. I was getting timeouts even when valid data was returned.

Just something to be aware of in the Modbus module, I don't think there is anyway arround this as by definition the resolution of the system is defined by the TICK_RESOLUTION

Cheers

Martin

18
Luminary Micro TM LM3SXXXX / New Luminary compiler IDE
« on: June 22, 2010, 06:27:59 PM »
Hi Everyone,

I've just come across this site http://atollic.com/index.php/download/truestudiostellaris which provides another IDE for developing for the Luminary Chips, looks like its Eclipse based but not sure if it uses GCC.

Not sure on prices but it looks like the lite version is free

See this other post for more IDE's http://www.utasker.com/forum/index.php?topic=864.msg3818#msg3818

I've not had a chance to try this yet, but I thought it might be of interest to people, escpecially as it supports JTAG debug via the Luminary JTAG adapters.

Cheers

Martin

Update:
I've also found this site http://www.coocox.org/Index.html again not tested anything but just making people aware of it.

19
Luminary Micro TM LM3SXXXX / Timer Based Operation of the ADC
« on: June 12, 2010, 06:54:24 PM »
Hi Mark,

I want the ADC in my LM3S1968 based project to just run in the background continuously just reading the 8 ADC inputs. In fact in my application I'm just using the ADC inputs as another 8 logic input lines. I've setup a 1ms hardware timer that I'm using to sample some input lines (3 lines used to sample a 3phase mains supply so I can work out the mains sequence).

By a bit of trial and error I've got something that works in the simulator (I've no access to the hardware until Monday).

I couldn't find much info on ADC configuration on the forum or in the documentation so I'm posting here describing what I've done. So that it will be of help to other users and you can also tell me if I've done something wrong.

Firstly I setup the hardware Timer as shown below

Code: [Select]
unsigned long MSTimerTick = 0;

static void timer_int(void)
{
    MSTimerTick++;
    PhaseMap();
}

static void fnConfigure_Timer(void)
{
    static TIMER_INTERRUPT_SETUP timer_setup = {0};                      // interrupt configuration parameters

    timer_setup.timer_reference = 2;                                     // timer channel 2
    timer_setup.int_type = TIMER_INTERRUPT;
    timer_setup.int_priority = PRIORITY_TIMERS;
    timer_setup.int_handler = timer_int;                                // set to 0 for no handler
    timer_setup.timer_mode = (TIMER_TRIGGER_ADC | TIMER_PERIODIC | TIMER_MS_VALUE); // period timer
    timer_setup.timer_value = 1;                                        // ms delay
    fnConfigureInterrupt((void *)&timer_setup);                          // enter interrupt for timer test
}

Am I correct in using TIMER_TRIGGER_ADC in the timer_mode setting?

Next I set-up the ADC as shown below

Code: [Select]

static void fnConfigureADC(void)
{
    ADC_SETUP adc_setup;                                                 // interrupt configuration parameters
    adc_setup.int_type = ADC_INTERRUPT;                                  // identifier when configuring
    adc_setup.int_handler = 0;                                          // handling function
    adc_setup.int_priority = PRIORITY_ADC;                               // ADC interrupt priority
    adc_setup.int_adc_single_ended_inputs = (ADC_CHANNEL_0 | ADC_CHANNEL_1 | ADC_CHANNEL_2 | ADC_CHANNEL_3 | ADC_CHANNEL_4 | ADC_CHANNEL_5 | ADC_CHANNEL_6 | ADC_CHANNEL_7); // ADC channels 0..3 as single ended inputs
    adc_setup.int_adc_differential_inputs = 0; // No ADC channels as differential inputs
    adc_setup.int_adc_mode = (ADC_CONFIGURE_ADC | ADC_TRIGGER_TIMER);  // start under timer control
    adc_setup.int_adc_averaging = HW_AVERAGING_64;                       // basic sampling speed is 1MHz but can be averaged to improve accuracy or reduce speed
    adc_setup.int_adc_result = usADC_samples;                            // location to save the samples to
    adc_setup.int_sequence_count = ADC_SEQUENCES;
    fnConfigureInterrupt((void *)&adc_setup);                            // configure and start sequence
}

I presume this is the correct way to set the ADC mode?
 
adc_setup.int_adc_mode = (ADC_CONFIGURE_ADC | ADC_TRIGGER_TIMER);

Next it is all started off in my application startup with the following lines

        fnConfigureADC();                                                //
        fnConfigure_Timer();                                            // Hardware timer used for Phase detection and ADC trigger

As I say this seems to work in the Simulator I just wanted to ensure I was doing the right thing.

Cheers

Martin

20
Hi Mark,

I've come across the problem mentioned here http://www.utasker.com/forum/index.php?topic=249.msg1011#msg1011 where GCC is complaining about an undefined reference to in my case memset.

I was just wondering if it was possible to #define memset to uMemset and memcpy to uMemcpy somewhere to allow GCC to use the routines defined in uTasker, rather than looking in its own libraries

Its not a big problem but just a thought.

The line that caused my problem was

    unsigned char IIC_WrByte[18] = {0xc0, 0x20};            // {address, register, data x 16}

Cheers

Martin

21
MODBUS / Changing the address of a Modbus Slave device
« on: June 05, 2010, 03:10:16 PM »
Hi Mark,

I have a simple Modbus serial slave device that will have a Modbus address of 250 on start-up, a Modbus master will communicate with it at address 255 and then assign it another Modbus address that it should use until it is power cycled. (When it will return to using an address of 250).

The slave address is defined within the structure ptrMODBUS_pars and is used in the call fnInitialiseMODBUS_port which sets up a Modbus port.

What is the best way to cleanly change a devices address, note this need to happen after the device had replied to the modbus message that caused the change of address, from memory. fnMODBUSPostFunction is not the correct place to handle this as this is called before the reply is sent back.

I could use a gateway as in this post http://www.utasker.com/forum/index.php?topic=670.msg2882#msg2882 but I would like to make use of all the utasker routines to handle different messages, also my slave will only ever have one address its just that it will change.

Cheers

Martin 

 

22
µTasker general / Port simulation
« on: May 19, 2010, 08:32:34 PM »
Hi Mark,

Do you have any information on how the port sim feature works in the simulator, I've found this post in the forum http://www.utasker.com/forum/index.php?topic=738.msg3213#msg3213 but I'd like to know if there is any more info available. Specifically what script commands are supported and can this be used to simulate UART activity as well as GPIO. I'm using the LM3Sxxxx targets but I guess its pretty generic.

Cheers

Martin




23
µTasker general / uTasker Documentation
« on: April 20, 2010, 01:37:14 PM »
Hi Mark,

I've just been going through my downloaded copies of the utasker documentation to check my copies are uptodate. And I've got a couple of suggestions.

1. Is it possible to indicate the version number of each document within its description on the website i.e. V0.05 etc. To check which versions I had I have to download every document, open it and check the footer. Maybe you could incorporate the document version in the filename?

2. Is it possible to have one zip file with all the documentation, maybe this zip file could also group documents into different folders depending on topics like "tcpip" "file systems" etc.

I also noticed that the uTaskerTELNET.pdf document seems to have disappeared from the website.

Cheers

Martin

24
µTasker general / Support for AUTOIP
« on: March 25, 2010, 11:13:31 AM »
Hi Mark,

How difficult would it be for uTasker to support AUTOIP IP address allocation, when in DHCP mode. So if a DHCP server cannot be found the board will fall back to a Fixed IP address, if defined, or if the fixed IP address is defined as 0.0.0.0 an AUTOIP address in the range 169.254.x.x would be chosen.

LWIP has an AUTOIP module which might give some implementation idea's http://lwip.wikia.com/wiki/AUTOIP

Also the standard is defined here http://tools.ietf.org/html/rfc3927

The process looks fairly simple and seems to consist of using the ARP protocol to test and broadcast addresses. Combined with NETBIOS names this would make uTasker able to setup its own IP address very easily.

Cheers

Martin

25
Hi Mark,

JUst out of interest which compiler to you think is the best for ARM development GCC (Rowley), IAR or Keil. Which in your experience produces the fastest most compact code. And also have you come across any significant bugs in any of them. I use Rowley at the moment but am thinking about wether to upgrade or switch compilers. Just today I've hit a problem where it looks like my code is compiling incorectly but this could just be optomisation screwing with the debugging.

Cheers

Martin

26
MODBUS / Simple Modbus Simulator
« on: September 07, 2009, 05:22:54 PM »
Hi Mark,

I want to make a simple modbus simulator that will resond to all 247 modbus addresses, I want it to compute the response depending on what address is read. i.e. if the input register at address 1 is read I would like the data returned to be 1, if adress 2 is read the data should be 2 etc. This is for testing purposes.

I know I could use MODBUS_SHARED_SERIAL_INTERFACES but this seems like a bit of overkill. I thought I might be able to use fnMODBUSuserFunction but how do I get this to be called for every address?

Cheers

Martin

27
µTasker general / IIC File system
« on: August 29, 2009, 10:31:24 AM »
Hi Mark,

I'd like to know how easy it would be to create an IIC file system, similar to the SPI file system. In my prodduct I have an IIC FRAM chip (fast write times, unlimited writes), and I was thinking of accessing this memory using the uTasker file access commands. I've got the following questions

1. Can you give me some pointers as to which routines, need modifying.

2. The simulator would need modifing to save of the IIC memory on shutdown, and restore it on powerup

3. I have other IIC pheripherals on the same bus, and would still want to be able to support those.

4. It would be nice if the internal Flash, SPI and IIC memory areas were all avalable at the same time, I currently don't have SPI flash so thats not an issue at the moment.

5. In anticipation of supporting other types of non volatile memory like SD cards and USB memory devices, maybe the file access commands need to have an extra parameter that specified which "device / memory area" they are reading from.

Cheers

Martin

28
µTasker general / Using uTasker to create a serial to Ethernet conveter
« on: August 26, 2009, 06:28:23 PM »
Hi Mark,

We have an application where we are looking for a serial to Ethernet converter (Having a virtual serial port on a PC that links via Ethernet to a physical serial port on a target microprocessor). I know there are a number of simple modules out there by Lantronix and Xport that provide this functionality, but I was wondering if this was anything you had looked at with uTasker.

I can forsee the most dificult part would be getting software to create the Virtual Serial port on the PC. I've seen the Com0Com project which allows ypu to use com2tcp but this solution seems a bit long winded.

Cheers

Martin

29
Hi Mark,

I'd like your advice on how to handle the following scenario in uTasker.

I have a task TASK_COMMS_TX which formats a message packet which is then sent out of a serial port using fnWrite(SerialPortID......  as well as sending a packet out on the serial port it also Starts a time-out timer using  

    uTaskerMonoTimer(TASK_COMMS_TX, (DELAY_LIMIT)(0.25*SEC), E_COMMS_TIMEOUT);     // Set Timeout timer for 250ms

I have another task TASK_COMMS_RX which handles the serial reception from the remote device, this task parses the received message. If it receives a valid reply then I want TASK_COMMS_TX to process the next message that may be waiting in its Queue. The reception of a valid message should also stop the above time-out timer using
    
    uTaskerStopTimer(TASK_COMMS_TX);                                     // stop timeout timer

TASK_COMMS_TX is configured to be in the state UTASKER_STOP, so it should only be woken by events.

What I want to do is use the input queue of TASK_COMMS_TX to cache incoming messages, that will be processed either after a valid reply to a previous message is received or a time-out from a previously transmitted message occurs. Am I correct in saying that if TASK_COMMS_TX is in the state UTASKER_SUSPENDED nothing can wake it, where as if its in the state UTASKER_STOP. Any event will wake it including the reception of another packet to be transmitted.

One way around this would be to have another task, to handle the Time out event and switch TASK_COMMS_TX into the UTASKER_STOP state when a timeout occurs, but this seems a bit untidy, 3 Tasks to handle a comms protocol.

Is the above the way to do this or is there a simpler way?

I hope the above makes sense

Cheers

Martin Honeywill

30
Hi,

I'm trying to use buttons on a PC Keyboard to simulate  buttons on my target device, making it easier to drive a user interface rather than clicking individual I/O pins with the mouse. I was planning to use the PC cursor keys to emulate a keypad, with other keys emulating an ok and esc button.

My thought was to add a variable KeyBoardCode into the WM_KEYDOWN event in WndProc() in WinSimMain.cpp, I could then examine this variable in my code to check for a keypress. I was planning to wrop this test so it was only compiled if running in simulation mode.

        case WM_KEYDOWN:
           KeyBoardCode = wParam;
           if (0x10 == wParam) {                                        // shift key down {11}
                iShiftPressed = 1;
            }
#ifdef SUPPORT_KEY_SCAN
            else if (VK_ESCAPE == wParam) {                              // ESC key pressed
                iInputChange = fnCheckKeypad(-1, -1, 0);
            }
#endif
            break;

I defined KeyBoardCode in application.c

    unsigned int KeyBoardCode;

And put an extern reference to it in application.h

    extern unsigned int KeyBoardCode;

When I compile this I get the error

    Error   1   error LNK2001: unresolved external symbol "unsigned int KeyBoardCode" (?KeyBoardCode@@3IA)   WinSimMain.obj   uTasker

Even though I know application.h is included via config.h in WinSimMain.cpp.

I'm not sure whats happening here, is it because I trying to include a variable defined in a C file in a C++ file?

Any help greatly appreciated

Cheers

Martin

Pages: 1 [2] 3