Author Topic: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK  (Read 156192 times)

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #75 on: November 30, 2010, 09:52:24 PM »
It appears I had a half crashed windows. Wireshark indicated I wasn't sending http traffic to the device IP. After the reboot, it now produces the expected 404. Even better when I transfer files it got about 15k of the file copied out of an expected 25k. Then it produced this message.

Unhandled exception at 0x004a3d13 in uTaskerV1-4.exe: 0xC0000005: Access violation writing location 0x00000000.

It brings me to line 346 of LPC23XXSIim.c. I think this means it ran out of memory. I'm not sure what memory might be small, or how to make an adjustment to it.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #76 on: November 30, 2010, 10:53:34 PM »
Hi

You need to see what routine this is happening in (check the call stack window to see where it came from).
What is happeing (as the error messages says) is that something is trying to write using a NULL pointer. This may be due to memory getting overwritten or due to a pointer not being set to a memory block since a uMalloc() failed.

Regards

Mark

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #77 on: November 30, 2010, 11:49:17 PM »
I feel a bit sheepish. I used the Copy_all.bat file and it copied just fine. When I copy the files, then use dir via FTP, it replies with just the first letter of the uploaded file. I would guess the upload process renames the files when they get there. When I copied via explorer, I had it copy both ftp.txt and ftp_del.txt which would both get renamed to f.txt. I believe that's the point where it lost its brains. I can get the stack info if you would like for diag purposes. I'm back up and running, and it would appear using the command line ftp is a reliable solution, so I'll go with it. At this point I should be able to start experimenting with getting a stream of data from the AIS226 chip.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #78 on: December 01, 2010, 12:01:12 AM »
Hi

The uFileSystem is described here: http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF

It is normal that the files are displayed with only their first letter or number. The utFAT allows directories, long names and compatibility with PCS - the uFileSystem is a simple file system but it is extremely fast in comparison and is adequate for a large amount of file storage and manipulation requirements in embeded projects. Once you have used it you will probably find that it is not that restrictive but easy to use - FAT based file systems will simply never be able to operate as fast as it can since it doesn't need to search for data of handle clusters.

Regards

Mark

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #79 on: December 01, 2010, 01:15:51 AM »
That's quite interesting. I can live with those constraints and I'm happy to have those performance enhancements at my finger tips. Thanks for the informative PDF.

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #80 on: December 03, 2010, 12:40:37 PM »
I'm looking to add two things to this proto board. One is to get a stream of the SPI data into a comma delimited file via HTTP, the other is to display the data on a web page.

To get a 1kb file on the PC it appears that I'm best off using £H20 instead of £H10 and creating a if statement like this under webinterface.c.
Code: [Select]
#ifdef HTTP_DYNAMIC_CONTENT                                              // {5}
        case 'H':

blah blah blah

else if (*ptrBuffer == '2') {
Is that the intended place for me to add such an item, or should I add this somewhere else similar to how I added it somewhere else like with my_first_task.c? 

I seem to recall seeing something that described the characters used in HTML parsing. Something that give a brief description of what these characters are and do.
Code: [Select]
£sO1Does such a document exist? I see there are several designators like that s, and a look up chart would be kind of handy. I've read the dynamic content generation document.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #81 on: December 03, 2010, 01:21:04 PM »
Hi

The file webInterface.c is a user application file and so additional dynamic generation segments can be aded here (as you have suggested).

The HTML control interface is described here: http://www.utasker.com/forum/index.php?topic=94.0

The actual control characters used are defined in config.h so they can be adjusted if necessary. The escape sequence length defaults to 4 characters but can be increased by defining WEB_ESCAPE_LEN in config.h (some projects prefer to use 5, but make sure that all tags in the HTML have the corresponding lengths).

Regards

Mark

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #82 on: December 05, 2010, 11:33:10 PM »
I'm having some trouble getting my code to work under webinterface.c. originally I had the SPI comm routine(s) in spi_acc_lpc_AIS226_2.h and #included in my-first-task.c. When I use that same #include in webinterface.c I get complaints from the linker that it's defined twice.
Code: [Select]
Compiling...
webInterface.c
Linking...
webInterface.obj : error LNK2005: _fnSPI_AIS226 already defined in my-first-task.obj
I'm a bit ignorant about exactly how Vissual C++ will compile this part. It appears it will compile anything listed in the solution explorer.

I put spi_acc_lpc_AIS226_2.h next to spi_flash_lpc_stmicro.h in the solution explorer, and I tried to mimic similar programming techniques. I don't know why it keeps trying to define them twice, I might guess I'm doing something wrong with the .h file. It includes prototype(s), #defines, then the functions themselves. I don't know how to modify the compile process to make them show up as a file that is referenced by both my-first-task and the .h file. Are there any suggestions on how to fix it. I can provide additional information if required, but I don't know what pieces of information might be wanted for looking at. Are there any chunks of information I can provide to help diagnose this issue?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #83 on: December 06, 2010, 01:23:58 PM »
Hi

It looks as though you have code in your header file and the header file is being included in more that one C-file. You have to avoid the 'code' in the header from being defined more than once or else there will be multiple copies of it and so the linker error.

For example, use a define in the header file like the following around your code (in the header):

#if defined _INCLUDE_THIS_CODE
... code
...
#endif


The header can now be incluided by multiple C-files but the code is not activated unless the calling file defines _INCLUDE_THIS_CODE. Define this only in the (single) file that you want to include it in. Eg.

#defined _INCLUDE_THIS_CODE
    #include "spi_acc_lpc_AIS226_2.h"
#undef _INCLUDE_THIS_CODE // optional


Regards

Mark

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #84 on: December 07, 2010, 02:20:43 AM »
I believe I see what your saying, but I'm not sure it's quite what I need. I tired a couple more attempts, but no dice yet. I think this will help show the problem. I have been trying several things like using static, vs extern, vs not specified. This is how it is now, and I think this may show the problem.

In my-first-task.c
Code: [Select]
#define _INCLUDE_AIS226
#include "../../hardware/LPC23XX/spi_acc_lpc_AIS226_2.h"  // AIS226 accelerometer
#undef _INCLUDE_AIS226

blah blah blah

y_now = (signed short)  fnSPI_AIS226(OUTY_L, SPI_READ, 0x00)
  + (signed short)((fnSPI_AIS226(OUTY_H, SPI_READ, 0x00) & HI_MASK) << 8);
In webinterface.c
Code: [Select]
#define _INCLUDE_AIS226
#include "../../hardware/LPC23XX/spi_acc_lpc_AIS226_2.h"  // AIS226 accelerometer
#undef _INCLUDE_AIS226

blah blah blah

y_now = (signed short)  fnSPI_AIS226(OUTY_L, SPI_READ, 0x00)
      + (signed short)((fnSPI_AIS226(OUTY_H, SPI_READ, 0x00) & HI_MASK) << 8);
In spi_acc_lpc_AIS226_2.h
Code: [Select]
#if defined _INCLUDE_AIS226 // include AIS chip
unsigned char fnSPI_AIS226(unsigned char cmd, unsigned char rw, unsigned char SPI_data){
unsigned long temp;
int temp2, null;

blah blah

return temp2;
}

#endif // stop including AIS chip
fnSPI_AIS226 is a function that sends 8 bits down the SPI and receives 8 bits from the SPI. Because I'm using it as my comm interface, I'm looking to call it from different c files as a kind of shared function. I tried using the #define and #undef to help limit the scope of when it's seen by the compiler, but it still complains "webInterface.obj : error LNK2005: _fnSPI_AIS226 already defined in my-first-task.obj"

I had expected that it would compile spi_acc_lpc_AIS226_2.h into an object file, as well as my-first-task.c and webinterface.c into their own object files. I expected my c file(s) would simply list a jump command in the object file and it would all come together during linking. But it appears it compiles a bit more literally. I understand that the #include will simply copy the specified file, replacing the include line when it's made into the object file. But I thought it would be a bit less literal than that. I was expecting it would copy just the jump command to the function, not the entire function.

I believe I would normally get around this by modifying my make file to specifically compile the .h file into the .o file, then I would make sure this .o file was a dependent of my-first-task and webinterface. It would then be included while linking and my functions would all pull together in the last compile step.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #85 on: December 07, 2010, 01:17:53 PM »
Hi

I think that the include of the code is still taking place twice and so the linker will still complain.

Try the following in your header file:

Code: [Select]
#if defined _INCLUDE_AIS226 // include AIS chip
extern unsigned char fnSPI_AIS226(unsigned char cmd, unsigned char rw, unsigned char SPI_data){
unsigned long temp;
int temp2, null;

blah blah

return temp2;
}
#else
    extern unsigned char fnSPI_AIS226(unsigned char cmd, unsigned char rw, unsigned char SPI_data);
#endif // stop including AIS chip

In webinterface.c include as you have done (make sure that the include is not within a function otherwise it will have syntax errors)

In my-first-task.c (don't activate the code in the include):

Code: [Select]
#include "../../hardware/LPC23XX/spi_acc_lpc_AIS226_2.h"  // AIS226 accelerometer
Regards

Mark



Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #86 on: December 08, 2010, 01:12:34 AM »
It works works spot on that way. I formated the string a bit and now I can process raw data via spread sheet, or other number crunching mechanisms.
« Last Edit: December 08, 2010, 04:05:06 AM by kb1gtt »

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #87 on: December 08, 2010, 04:43:30 AM »
I'm having a bit of a problem when I run it on the target. I have a solid supply, or at least its solid at the board header. With a scope I measured both the 3.3v and 5v, neither appear to drop more than 10% even in short bursts, and both look very solid on the average, not noticeable ripple on the scope. A while back I had thought the problem was caused by slightly exceeding the power supply's limits, but it's now on a different supply that should be overly capable. When it fails, it locks up, the heartbeat LED stops blinking, ect. Most of the time it will come out of it by pressing the proto board's rest button, but not always. Sometimes I have to wait for 30 seconds or so and it self resets. Some times it runs for as little as 1 or 2 seconds, and it rarely lasts longer than 15 seconds.

I don't have much for external or extra devices attached to it. I have two SSR's that draw about 1.5ma each (pin spec is 4ma max), the AIS226 chip, then the typical eth and 232 wires. That's about it. I can't help but feel it has to be software related. I found an Older demo firmware titled uTaskerV1.3_Olimex_LPC2378-STK.hex it seems to work fine. Just blinks an LED.

I'm a bit baffled about how to figure out why it's locking up. I have the Olimex ARM-USB-OCD jtag device, so perhaps I can diagnose it with the jtag. Not sure. Any suggestions would be appreciated. I guess for now I'll keep playing with it in the simulator, but it would be nice to get real raw data.

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #88 on: December 28, 2010, 12:24:50 PM »
I've been working with the simulator, and I'm currently trying to get data in and out of my-first-task.c such that I can modify parameters in my-first-task.c via web browser. I think one of the better ways to do this is by passing messages from my case in webinterface.c. In my-first-task.c I have this section of code.

QUEUE_HANDLE PortIDInternal = ptrTaskTable->TaskID;
unsigned char ucInputMessage[MEDIUM_MESSAGE];

while (fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH)) {

On the first pass of that section, PortIDInternal is = 0, ucInputMessage has a bunch of junk in it, and HEADER_LENGTH = 4. In driver.c, when it tries to return from fnRead, it crashes with this message
Code: [Select]
Unhandled exception at 0x00000000 in uTaskerV1-4.exe: 0xC0000005: Access violation reading location 0x00000000.

I'm a bit baffled about what the problem could be. The return statement doesn't make a lot of sense to me. I expect that because it shouldn't have a message to read, it should return 0. Perhaps I'm doing something invalid with the HEADER_LENGTH?
"unhandled exception"

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #89 on: December 28, 2010, 03:00:11 PM »
Hi

If PortIDInternal  is 0 it sounds as though there is no queue allocated to the task - this will result in an exception due to a null pointer as in your case.
Check the following entry in the task table:

{ "x marks my first task!!", fnMyFirstTask, NO_QUE,(DELAY_LIMIT)(5 * SEC), (DELAY_LIMIT)(2 * SEC),  UTASKER_STOP},

This is the simplest task without a queue.

To add a queue to the task add a queue length such as

{ "x marks my first task!!", fnMyFirstTask, SMALL_QUEUE,(DELAY_LIMIT)(5 * SEC), (DELAY_LIMIT)(2 * SEC),  UTASKER_STOP},

Regards

Mark

P.S. Sending a message to a task without a queue will not result in an error but the message will not be sent anywhere. This can also be seen from the return value to the queue write which will be 0.