0

I am very very new to microchips programming.

I have several questions.

  1. I couldn't figure out how to set oscillator frequency in the in mikroC Pro for pic32. I can do it in edit-projects setting, but I want to set the value in the code.

  2. Secondly, I couldn't figure out how to set RA2, pin 9, as an output.

I have done the following but I couldn't make the pin as output

define StepperDisable LATA.F2 // Output

define StepperDisableDir TRISA.F2

StepperDisableDir = Out;

If you could help me I will be really appreciated. As I said, I have done software programming but not in very very low level, hardware programming

Thanks a lot

Community
  • 1
  • 1

2 Answers2

0

To set as output FIRST set the _TRISA2 = 0 then set _LATA2 = 1, if you do the other way around the latch will not take and then the output will be set to out, but will be low. I as speaking from using the XC32 compiler, so _TRIS/_LAT may not exist, but the same should be able to be done with the LATA.F2 and TRISA.F2

#define StepperDisable    _LATA2
#define StepperDisableDir _TRISA2
#define OUTPUT  0
#define INPUT   1

#define HIGH    1
#define LOW     0

StepperDisableDir = OUTPUT
StepperDisable = HIGH

As for the oscillator, which one are you speaking of? The PIC32 instruction clock oscillator? Or the PWM?

blsmit5728
  • 434
  • 3
  • 11
0

Make sure to turn off Analog pins and JTAG, these can sometimes cause issues on certain pins.

AD1PCFG = 0xFFFF; //!< Make sure the Analog PINS are off
DDPCONbits.JTAGEN  = OFF;
DDPCONbits.TDOEN   = OFF;
DDPCONbits.TROEN   = OFF;
blsmit5728
  • 434
  • 3
  • 11