I have an experience programming PIC18 in C using CCS Compiler. I wanted to learn how to program uC32 Arduino compatible PIC32 based development board. I can either use MPLAB IDE or MPIDE as compiler for uC32. I have no experience at all with either of these IDE's. Could you please guide me? Thank you.
I've used the Arduino IDE with a chipKIT PIC32 board (not sure which one?), and it worked fine - just follow the instructions for installing the board in the IDE.
I have a small project in mind which I think would help me to learn PIC32 better. Possibly a small car robot. I'm planning to start learning uC32 on the weekend.
Suppose I want to display the readings on this display from some device wirelessly. What components would I need to achieve it? What type of transmitter and received should be used?
I understand that I'd need a separate microcontroller to hook up the display to. In other words the display would constitute an independent and separate system which receives the input from another system wirelessly and display it. We can assume that the information to be displayed is very basic.
Suppose I want to display the readings on this display from some device wirelessly. What components would I need to achieve it? What type of transmitter and received should be used?
I understand that I'd need a separate microcontroller to hook up the display to. In other words the display would constitute an independent and separate system which receives the input from another system wirelessly and display it. We can assume that the information to be displayed is very basic.
Obviously you need 'something' at either end of a radio link but you don't need a 'separate' one for the display, the one that's doing the receiving can VERY easily drive the display. The little OLED displays are usually I2C, so connect to the processor using just two pins.
As for what to use, check out the numerous Arduino examples - there are a wide variety of different types of wireless modules available - a lot depends what kind of range you're looking for?. If range is only short, then the extremely cheap simple wireless modules will do all you need.
There are various ways, the nRF24L01 is just one of them - the HC12 radio modules are more expensive, but much easier to use, and have a much greater range. If you want 'cheaper' there are the crude and simple ASK modules, and there are Arduino libraries to use all of them.
As I recall, the RadioHead Library is the usual Arduino one, and has replaced the VirtualWire Library that used to be used on the simple ASK modules.
Please let me know if I need to install any other file to run uC32 properly.
I haven't yet tried to run any program (or, in Arduino terminology 'sketch') but I have two questions.
Question 1:
I wrote the following code for PIC18 years ago and was wondering if there is a way to write the code in similar fashion in Arduino IDE as well. As you already know Arduino sketch is written using this format.
Note to self:
The bootloader is basically a .hex file that runs when you turn on the board. It is very similar to the BIOS that runs on your PC. It does two things. First, it looks around to see if the computer is trying to program it. If it is, it grabs the program from the computer and uploads it into the ICs memory (in a specific location so as not to overwrite the bootloader). That is why when you try to upload code, the Arduino IDE resets the chip. This basically turns the IC off and back on again so the bootloader can start running again. If the computer isn't trying to upload code, it tells the chip to run the code that's already stored in memory. Once it locates and runs your program, the Arduino continuously loops through the program and does so as long as the board has power.
Source: https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader/all
#define LED PIN_D2
void setup() {
pinMode(LED, OUTPUT); // sets the digital PIN_D2 as output
}
void loop() {
digitalWrite(LED, HIGH); // sets the digital PIN_D2 on
delay(1000); // waits for a second
digitalWrite(LED, LOW); // sets the digital PIN_D2 off
delay(1000); // waits for a second
}
Question 2 No... You need to program the uC32 with MPLAB or similar..
looky here..
#define LED PIN_D2
void setup() {
pinMode(LED, OUTPUT); // sets the digital PIN_D2 as output
}
void loop() {
digitalWrite(LED, HIGH); // sets the digital PIN_D2 on
delay(1000); // waits for a second
digitalWrite(LED, LOW); // sets the digital PIN_D2 off
delay(1000); // waits for a second
}
The original code was written in C for CCS compiler. Arduino IDE also uses C language then why different syntax; for example, why "digitalWrite" instead of "output_high". Does it depend more on the compiler or IDE than on the language used for coding?
On the other hand, my original question was different but I phrased it poorly. In the code I mentioned, there is no "void setup()" or "void loop()"; the C code only uses "void main()". I wanted to ask if there is a way to configure Arduino IDE code so that we can write the code using "void main()".
Question 2 No... You need to program the uC32 with MPLAB or similar..
looky here..
[/QUOTE]
I have found many conflicting answers to this one. I know that you use PIC32 but not sure if it's some chipKIT development board by Digilent. Anyway, a couple of days I asked the same question on Digilent's official forum and here is the answer by Digilent's representative. Could you please comment on it? Thank you!
The original code was written in C for CCS compiler. Arduino IDE also uses C language then why different syntax; for example, why "digitalWrite" instead of "output_high". Does it depend more on the compiler or IDE than on the language used for coding?
No it doesn't, it uses C++, but (as far as I'm aware?) 'output_high' isn't a standard C function anyway, and nor is 'digitalwrite' a standard C++ function - both are specific individual functions of the particular compiler/IDE. In the digitalwrite case (at least) it hides the hardware from you, and GREATLY slows the speed of access.
The whole point of the chipKIT is to use the Arduino IDE, and the VAST amount of code that's already out there - if you want to run plain C then use MPLABX and connect a PK3/4 to the chipKIT, overwrite the bootloader, and forget about Arduino all together (but in which case, why buy a chipKIT?).
Mine IS a chipkit... The chipKIT MAX32 to be correct... It's the same as yours but has oodles more pins... It's more like the Arduino Yun
https://reference.digilentinc.com/chipkit_max32/refmanual <--- Here be a lot of answers... I had to write the MPIDE bootloader as I had already erased the original.. But once the bootloader is seen by the Arduino IDE it all falls into place.
As per Nigel's comments... The Arduino IDE is indeed primarily a C++ environment.. BUT!!! The whole thing is based on the AVR C compiler and can be used with C style syntax with no issues..
The sketch
Code:
// We have globals first as all code
// then the setup() function
void setup(void)
{
// stuff todo..
}
then we have a loop() function
void loop(void)
{
// stuff todo..
}
//THEN!! this bit is added on compile.. You do not see this!!
void main(void)
{
setup();
while(1)
loop();
}
So the arduino creates the same code as normal C/C++ coders use before the compile process..
No need to think any different.
As to the pinmode() function etc.. All these are prewritten wrapper functions...
https://reference.digilentinc.com/chipkit_max32/refmanual <--- Here be a lot of answers... I had to write the MPIDE bootloader as I had already erased the original.. But once the bootloader is seen by the Arduino IDE it all falls into place.
The uC32 board is designed to be used with the Multi-Platform IDE (MPIDE). MPIDE is a modified version of the
Arduino IDE that supports the PIC32 microprocessors and is backwards-compatible with the Arduino IDE. The
MPIDE uses a serial communications port to communicate with a boot loader running on the uC32 board. The
serial port on the uC32 board is implemented using an FTDI FT232R USB serial converter. Before attempting to use
the MPIDE to communicate with the uC32, the appropriate USB device driver must be installed.
[...]
Using the Microchip development tools to program the uC32 board will cause the boot loader to be erased. To use
the board with the MPIDE again, it is necessary to program the boot loader back onto the board. The boot loader
image can be downloaded from the Digilent Uno32 product page.
The following is from the reference manual of chipKIT Max32 quoted by Ian Rogers .
Using the Microchip development tools to program the Max32 board will cause the boot loader to be erased. To use the board with the MPIDE again, it is necessary to program the boot loader back onto the board. The boot loader source code and compiled image can be found in the MPIDE software download. You may also download it from the Max32 product page **broken link removed**. Once you have the boot loader .hex file, complete the following steps to reload the boot loader to the PIC32 microcontroller using MPLAB® X.
Ian Rogers I think you used your Max32 with MPLAB and then to use it again with MPIDE or Arduino IDE you needed to upload the bootloader.
"Before attempting to use the MPIDE to communicate with the uC32, the appropriate USB device driver must be installed." - Do I need to install the driver and where can I find it?