Modification of J1939 C Library for PIC32 - c

I am working on a project based on J1939 Interface. I am using J1939 C Library for PIC 18 devices (AN930), I am wondering how can I modify this library to work with PIC32MX795F512L device?
I am not the expert level programmer and started working on PIC32 couple of month ago.
Please guide me.
Thank you

If the library was developed the right way, then you only need to find out the clock that controls the timing for the messages; and route it to the right configuration; also you need to identify the buffer where you are going to be receiving the messages, and route it to the library.

That library is outdated and devs stopped updating it. It is designed for C18 compilers. If you want to use that library in XC18 or any other compiler you have to make some major changes in J1939.c file. I do not recommend to spend your time with it, you can implement new one by refering datasheet of your microcontroller, it would be so much easier. Good Luck!

Related

Can you open and edit .c files in the Arduino IDE? And subsequently load them to an Arduino board

I have been trying to open c files in the Arduino IDE (which some people claim is possible).
I have not been able to do so.
How can I program the Arduino in c given that I have a project/files in another IDE? (for example, MPLABX)
I am not sure what you are trying to archive. Is it that you want to open it via the Arduino IDE or also compile the source code?
I am not aware of programming in bare c in the Arduino IDE. But if you're looking into using real c code, it might be a good time start either compiling and uploading via terminal yourself, or use an IDE which is suited for development with micro controllers.
I think you can tell the Arduino IDE to more elaborately log outputs. This would tell you exactly the commands the IDE is using (uses avrdude). Then you can use an IDE/Editor of your choice for coding.
Otherwise, have a look at eg. Atmel Studio. They also support Arduino.
There are two answers in one:
If you really want to use the ArduinoIDE you have to have a basic *.ino file having at least the defines and includes which are in the project file and the reqiured setup() loop() usually whats in main in c goes to loop() in ArduinoIDE. Thats the stoney path because there are some specific issues coming from the philosophy behind ArduinoIDE (help makers with little (no?) programming skills to get started quickly).
If you just need the Arduino tool-chain and want to work more comfortable you have two other options:
EclipseIDE with the Sloeber add-on. Download the Sloeber-AllInOne-Package for an easy start and THEN add the other modules you need (like for web development or similar)
PlatformIO an IDE for micro controller development - there is also a cloud based version for testing around.
All mentioned tools are real open source and available cross PC platform and not a gift from a company like MS for probably later lockin of devs

C or C++ programming with contikiOS on Arduino Due

What I need to do is to compile and run a program written in C/C++ on Arduino.
I'm ok with every open source RTOS if it supports C especially struct.
So I have found contikiOS does that, and tried to get started.
But I guess contikiOS doesn't support Arduino port anymore and Due is quite recent model so that I couldn't find proper information.
If you know any information on it or want me to help, please give me an advice.
Ah, do you have any other recommendation for RTOS?
Thanks.
If what you need is to run a simple c/c++ software, you have to know that the arduino environment support c/c++ code, as explained in the arduino homepage http://code.google.com/p/arduino/
If for your requirements, you need to use a real time operating system, there is a contikiOS version for Arduino (Contiki-Arduino).
Last but not least, if you are a beginner, i would advice you to use a popular RTOS, to find support on internet easily if you need it. Sadly, i am not an expert on that field. But when i google it, i find Duinos, maybe you could have a look on it.

threads calling other programs

I recently worked on two things : receiving data from the serial port (TinyOS and seriallisten) and capturing frames from a webcam (OpenCV). Now I want to use both together. I want to use modify the video quality according to the rssi received on the serial port.
I've been told that I can create a program which creates thread that would call the methods I previously used : camcapture.c and seriallisten.c, but I don't know how to do this.
Can someone explain it ?
Thanks
You should look int Boost Threads. There are examples on the web on how to create a program and use Boost Threads to call either a class method or a non-class static method.
About using C++ library in C code, this stackoverflow post may be helpful. I guess using extern scope operator is the magic here. C++ cross-compiler is designed using C, so backward conversion is not impossible.
If you hit success in using C++ into C
Wikipedia listed these for Multithreading libraries for C++. I guess it is worth visiting those and see what is good. Boost is still the best IMPO.
P.S. You should checkout intel's Threading Building Block TBB too. They are quite good and simple. Open source projects such as OpenCV uses tbb for their multithreaded class ops. the link is here

Invensense IMU3000 with microcontroller PIC

Has anybody experienced using the Invensense IMU3000 with some microcontroller?
I am trying to build the IMU library for a PIC but I am stuck with the dependencies.. any other experience with others microcontrollers will be nice as well!
Basically I don't get whether it is better to take the Visual Studio 2005 project and make the changes there, adding the PIC dependencies (I get stuck..) or compile the whole library in the PIC environment..
Any hint, even with other platforms, would help!
Thank you all!
PC and PIC programming are so very different... Also there are so many pIC variants, they are hugely different from each other, it's hard to answer such an open ended question. However, basically you're writing mathematical algorithms. So write these as ansi c functions, hosted with a load of PC things (dialogs etc) and once they're working, you can move just the math functions over to the PIC - having already got a framework running on the PIC, ready to receive the algorithms. BUT - take care with memory. You have bags of it on the PC, you have to be mean with memory once you work on a PIC. Good luck, enjoy!
While it can be helpful to write code on the PC that will eventually move to the PIC, you will need to make sure that all code that will move has been written with portability in mind. That is, you cannot assume that code that compiles and works perfectly under Visual Studio will work without modification on any other platform.
To run in the PIC, all of the code must be compiled with cross development tools that are designed to target the PIC.
That said, I often develop algorithms and detailed processing code in the PC where a test suite can be easily used to verify its operation, and then recompile it for my target platform.
Incidentally, Google tells me that the IMU-3000 is a MEMS Gyro. It would probably be helpful to include at least the link to its data sheet in the question.

I'm having trouble finding example code for libftdi's mpsse (SPI) mode

This is not a homework problem, though it is a work problem. Where months ago, I would have just written up a specification and the boss would have contracted it out, money's tight. So I'm trying to do this myself.
I'm a weak C coder, and I'm lucky if gcc spits out something that will run without segfaulting, or sometimes anything at all. Still, I manage. Libftdi is built, I've carefuly perused both its example executables/code, and the documentation. But I'm still lost.
Does anyone know of a software project that makes use of its MPSEE mode, that's hooked into an SPI device? Is anyone here slick enough to provide an example? I could really use the help. I don't need this handed to me on a silver platter, but I'm having trouble even getting started. If I could even figure out how to initialize it and send a byte to the chip on the other side of the FTDI ic, I think I might manage to muddle my way through it.
Any help appreciated.
Flashrom can use FT2232 SPI mode: http://flashrom.org/Downloads

Resources