• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

learning to program uC32 which is PIC32 based Arduino compatible development board

PG1995

Active Member
Hi,

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.
 

PG1995

Active Member
Thanks.

Someone told me that Arduino IDE could be used with it. BTW, have you used uC32?
 

Nigel Goodwin

Super Moderator
Most Helpful Member
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.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Thanks.

Someone told me that Arduino IDE could be used with it. BTW, have you used uC32?
Yeah!! Me.. Which uC32 have you got?


In the Arduino IDE choose boards manager and scroll to uC32 and install... You will need to load the Arduino firmware via MPLAB but that is simple..
 

PG1995

Active Member
Yeah!! Me.. Which uC32 have you got?
And I found many of your posts about PIC32 here on this forum! :) This is the IDE for 8051 I was talking about: https://en.wikipedia.org/wiki/MCU_8051_IDE

There is only one uC32: https://store.digilentinc.com/uc32-arduino-programmable-pic32-microcontroller-board/ . It's possible that in the past they had more versions of uC32. uC32 is pin compatible with Arduino Uno. Then there is Max32 which is pin compatible with Arduino Mega.

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.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Dillegent had several units... They seem to have moved on...

Another set you can use is pinguino from Olimex... Cheaper and virtually the same..

I use the Micro version
 

gophert

Well-Known Member
Most Helpful Member

PG1995

Active Member
I have this display, UCTRONICS 0.96 Inch OLED Module: https://www.amazon.com/gp/product/B072Q2X2LL

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.

Thank you
 

Nigel Goodwin

Super Moderator
Most Helpful Member
I have this display, UCTRONICS 0.96 Inch OLED Module: https://www.amazon.com/gp/product/B072Q2X2LL

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.

Thank you
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.
 

PG1995

Active Member
I think I would need two ICs nRF24L01.

The following videos are relevant here.
/watch?v=7rcVeFFHcFM (put youtube.com in front)
/watch?v=Zd3h6SrsGZM&t=264s
 

Nigel Goodwin

Super Moderator
Most Helpful Member
I think I would need two ICs nRF24L01.

The following videos are relevant here.
/watch?v=7rcVeFFHcFM (put youtube.com in front)
/watch?v=Zd3h6SrsGZM&t=264s
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.
 

PG1995

Active Member
Hi,

Today I installed Arduino IDE and then tried to configure uC32 following the steps given below.

Step 1:
chipkit.net/wiki/index.php?title=How-To_Install_chipKIT_Core
Step 2:
https://chipkit.net/wiki/index.php?title=Main_Page ---> https://chipkit.net/wiki/index.php?title=Basic_IO_Shield#uC32

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.

C:
#include <18f46k22.h>
#fuses  PLLEN,NOWDT, NOPUT, NOPROTECT, NOBROWNOUT,NOLVP INTRC_IO
#use delay(clock=64000000)

#define LED PIN_D2

void main() {

output_high(pin_d3);

while(TRUE) {
   delay_ms(15000);
   output_toggle(LED);
   }
}
Question 2:
Does uC32 come preloaded with Arduino bootloader?


Relevant links:
1: https://www.arduino.cc/en/Hacking/DFUProgramming8U2
2: https://shop.evilmadscientist.com/productsmenu/564#

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

Note to self:
Don't confuse chipKIT with PICkit. Check https://pic-microcontroller.com/chipkit-development-board/
 

Attachments

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Question 1.
C:
#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.. https://blog.digilentinc.com/reinstall-and-update-bootloaders-on-chipkit-boards/
 

PG1995

Active Member
Question 1.
C:
#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
}
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?

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.. https://blog.digilentinc.com/reinstall-and-update-bootloaders-on-chipkit-boards/
[/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!
 

Nigel Goodwin

Super Moderator
Most Helpful Member
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?).

Edit:

Following on from earlier, I've finally found my 'chipKIT', it's a Fubarino. https://wiki.seeedstudio.com/Fubarino_SD/
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
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...
 

PG1995

Active Member
Following on from earlier, I've finally found my 'chipKIT', it's a Fubarino. https://wiki.seeedstudio.com/Fubarino_SD/
Thank you.

I didn't know that chipKIT also had its clones/forks available.

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 following is from reference manual of uC32.
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 here. 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?

Please check out this Amazon review.

Thank you.
 

Latest threads

EE World Online Articles

Loading
Top