Skip to content

Commit 0b19a6e

Browse files
committed
Pull request #34: Develop
Merge in MCU16CE/dspic33a-curiosity-oob from develop to master * commit 'b038974f1c09efee878474c787d1798926135fdc': Update version numbers and change log Restore main back to original state and stub in unused functions in bsp files Re-add bsp files and abstract adc calls Replace bsp with MCC modules
2 parents f7593cd + b038974 commit 0b19a6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4608
-766
lines changed

.main-meta/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"content":{
55
"metaDataVersion":"1.3.0",
66
"name":"com.microchip.mplabx.project.dspic33a-curiosity-oob",
7-
"version":"1.0.0",
7+
"version":"1.1.0",
88
"displayName":"dsPIC33A Curiosity Out of Box Demos",
99
"projectName":"dspic33a-curiosity-oob",
1010
"shortDescription":"dsPIC33A Curiosity Out of Box Demos",

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# dspic33a-curiosity-oob v1.1.0
2+
### Release Highlights
3+
1. Update dsPIC33AK128MC106 GP DIM demo to use MCC generated peripherals (v1.1.0)
4+
5+
6+
### Features Added\Updated
7+
1. Update dsPIC33AK128MC106 GP DIM demo to use MCC generated peripherals (v1.1.0)
8+
19
# dspic33a-curiosity-oob v1.0.0
210
### Release Highlights
311
1. dsPIC33AK128MC106 GP DIM support added

dspic33ak128mc106_gp_dim/.main-meta/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"content":{
55
"metaDataVersion":"1.3.0",
66
"name":"com.microchip.mplabx.project.dspic33ak128mc106-gp-dim-oob",
7-
"version":"1.0.0",
7+
"version":"1.1.0",
88
"displayName":"dsPIC33AK128MC106 GP DIM Curiosity Out of Box Demo",
99
"projectName":"dspic33ak128mc106_gp_dim",
1010
"shortDescription":"dsPIC33AK128MC106 GP DIM Curiosity Out of Box Demo",

dspic33ak128mc106_gp_dim/dspic33ak128mc106_gp_dim.X/bsp/led_blue.c

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,47 @@
2121

2222
#include <xc.h>
2323
#include "led_blue.h"
24+
#include "../mcc_generated_files/pwm/sccp3.h"
2425

25-
void LED_BLUE_Initialize(void)
26+
static bool issccp3Enabled = false;
27+
28+
void LED_BLUE_Initialize(void)
2629
{
27-
TRISDbits.TRISD2 = 0;
28-
29-
/* PWM control register configuration */
30-
PCLKCONbits.MCLKSEL = 0b1;
31-
32-
PG1CON = 0;
33-
PG1CONbits.CLKSEL = 1;
34-
PG1CONbits.MODSEL = 0b000; /* Independent edge triggered mode */
35-
36-
PG1IOCON = 0;
37-
PG1IOCONbits.PMOD = 0b10; /* Independent mode */
38-
PG1IOCONbits.PENH = 1; /* High output enabled */
3930

40-
/* PWM uses PG1DC, PG1PER, PG1PHASE registers */
41-
/* PWM Generator does not broadcast UPDATE status bit state or EOC signal */
42-
/* Update the data registers at start of next PWM cycle (SOC) */
43-
/* PWM Generator operates in Single Trigger mode */
44-
/* Start of cycle (SOC) = local EOC */
45-
/* Write to DATA REGISTERS */
46-
PG1PER = 0x10000; /* PWM frequency */
47-
PG1DC = 0x8000; /* 50% duty */
48-
49-
PG1CONbits.ON = 0;
5031
}
5132

5233
void LED_BLUE_On(void)
5334
{
54-
PG1CONbits.ON = 1;
35+
SCCP3_PWM_Enable();
36+
issccp3Enabled = true;
5537
}
5638

5739
void LED_BLUE_Off(void)
5840
{
59-
PG1CONbits.ON = 0;
41+
SCCP3_PWM_Disable();
42+
issccp3Enabled = false;
6043
}
6144

6245
void LED_BLUE_Toggle(void)
6346
{
64-
PG1CONbits.ON ^= 1;
47+
if (issccp3Enabled == true)
48+
{
49+
LED_BLUE_Off();
50+
}
51+
else
52+
{
53+
LED_BLUE_On();
54+
}
6555
}
6656

6757
void LED_BLUE_Set(bool on)
6858
{
69-
PG1CONbits.ON = on;
59+
7060
}
7161

7262
void LED_BLUE_SetIntensity(uint16_t request)
7363
{
74-
while(PG1STATbits.UPDATE == 1)
75-
{
76-
}
77-
78-
PG1DC = request;
79-
80-
PG1STATbits.UPDREQ = 1;
64+
SCCP3_PWM_DutyCycleSet(request);
8165
}
8266

8367
const struct LED_DIMMABLE ledBlue =

dspic33ak128mc106_gp_dim/dspic33ak128mc106_gp_dim.X/bsp/led_green.c

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,47 @@
2121

2222
#include <xc.h>
2323
#include "led_green.h"
24+
#include "../mcc_generated_files/pwm/sccp2.h"
25+
26+
static bool issccp2Enabled = false;
2427

2528
void LED_GREEN_Initialize(void)
2629
{
27-
TRISDbits.TRISD0 = 0;
28-
29-
/* PWM control register configuration */
30-
PCLKCONbits.MCLKSEL = 0b1;
31-
32-
PG2CON = 0;
33-
PG2CONbits.CLKSEL = 1;
34-
PG2CONbits.MODSEL = 0b000; /* Independent edge triggered mode */
35-
36-
PG2IOCON = 0;
37-
PG2IOCONbits.PMOD = 0b10; /* Independent mode */
38-
PG2IOCONbits.PENH = 1; /* High output enabled */
3930

40-
/* PWM uses PG2DC, PG2PER, PG2PHASE registers */
41-
/* PWM Generator does not broadcast UPDATE status bit state or EOC signal */
42-
/* Update the data registers at start of next PWM cycle (SOC) */
43-
/* PWM Generator operates in Single Trigger mode */
44-
/* Start of cycle (SOC) = local EOC */
45-
/* Write to DATA REGISTERS */
46-
PG2PER = 0x10000; /* PWM frequency */
47-
PG2DC = 0x8000; /* 50% duty */
48-
49-
PG2CONbits.ON = 0;
5031
}
5132

5233
void LED_GREEN_On(void)
5334
{
54-
PG2CONbits.ON = 1;
35+
SCCP2_PWM_Enable();
36+
issccp2Enabled = true;
5537
}
5638

5739
void LED_GREEN_Off(void)
5840
{
59-
PG2CONbits.ON = 0;
41+
SCCP2_PWM_Disable();
42+
issccp2Enabled = false;
6043
}
6144

6245
void LED_GREEN_Toggle(void)
6346
{
64-
PG2CONbits.ON ^= 1;
47+
if (issccp2Enabled == true)
48+
{
49+
LED_GREEN_Off();
50+
}
51+
else
52+
{
53+
LED_GREEN_On();
54+
}
6555
}
6656

6757
void LED_GREEN_Set(bool on)
6858
{
69-
PG2CONbits.ON = on;
59+
7060
}
7161

7262
void LED_GREEN_SetIntensity(uint16_t request)
7363
{
74-
while(PG2STATbits.UPDATE == 1)
75-
{
76-
}
77-
78-
PG2DC = request;
79-
80-
PG2STATbits.UPDREQ = 1;
64+
SCCP2_PWM_DutyCycleSet(request);
8165
}
8266

8367
const struct LED_DIMMABLE ledGreen =

dspic33ak128mc106_gp_dim/dspic33ak128mc106_gp_dim.X/bsp/led_red.c

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,47 @@
2121

2222
#include <xc.h>
2323
#include "led_red.h"
24+
#include "../mcc_generated_files/pwm/sccp1.h"
25+
26+
static bool issccp1Enabled = false;
2427

2528
void LED_RED_Initialize(void)
2629
{
27-
TRISCbits.TRISC2 = 0;
28-
29-
/* PWM control register configuration */
30-
PCLKCONbits.MCLKSEL = 0b1;
31-
32-
PG4CON = 0;
33-
PG4CONbits.CLKSEL = 1;
34-
PG4CONbits.MODSEL = 0b000; /* Independent edge triggered mode */
35-
36-
PG4IOCON = 0;
37-
PG4IOCONbits.PMOD = 0b10; /* Independent mode */
38-
PG4IOCONbits.PENH = 1; /* High output enabled */
3930

40-
/* PWM uses PG4DC, PG4PER, PG4PHASE registers */
41-
/* PWM Generator does not broadcast UPDATE status bit state or EOC signal */
42-
/* Update the data registers at start of next PWM cycle (SOC) */
43-
/* PWM Generator operates in Single Trigger mode */
44-
/* Start of cycle (SOC) = local EOC */
45-
/* Write to DATA REGISTERS */
46-
PG4PER = 0x10000; /* PWM frequency */
47-
PG4DC = 0x8000; /* 50% duty */
48-
49-
PG4CONbits.ON = 0;
5031
}
5132

5233
void LED_RED_On(void)
5334
{
54-
PG4CONbits.ON = 1;
35+
SCCP1_PWM_Enable();
36+
issccp1Enabled = true;
5537
}
5638

5739
void LED_RED_Off(void)
5840
{
59-
PG4CONbits.ON = 0;
41+
SCCP1_PWM_Disable();
42+
issccp1Enabled = false;
6043
}
6144

6245
void LED_RED_Toggle(void)
6346
{
64-
PG4CONbits.ON ^= 1;
47+
if (issccp1Enabled == true)
48+
{
49+
LED_RED_Off();
50+
}
51+
else
52+
{
53+
LED_RED_On();
54+
}
6555
}
6656

67-
void LED_RED_Set(bool on)
57+
void LED_RED_Set(bool on)
6858
{
69-
PG4CONbits.ON = on;
59+
7060
}
7161

7262
void LED_RED_SetIntensity(uint16_t request)
7363
{
74-
while(PG4STATbits.UPDATE == 1)
75-
{
76-
}
77-
78-
PG4DC = request;
79-
80-
PG4STATbits.UPDREQ = 1;
64+
SCCP1_PWM_DutyCycleSet(request);
8165
}
8266

8367
const struct LED_DIMMABLE ledRed =

dspic33ak128mc106_gp_dim/dspic33ak128mc106_gp_dim.X/bsp/led_rgb.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929

3030
void LED_RGB_Initialize(void)
3131
{
32-
ledRed.initialize();
33-
ledGreen.initialize();
34-
ledBlue.initialize();
32+
3533
}
3634

3735
void LED_RGB_On(void)
@@ -57,9 +55,7 @@ void LED_RGB_Toggle(void)
5755

5856
void LED_RGB_Set(bool on)
5957
{
60-
ledRed.set(on);
61-
ledGreen.set(on);
62-
ledBlue.set(on);
58+
6359
}
6460

6561
void LED_RGB_SetColor(uint8_t red, uint8_t green, uint8_t blue)

dspic33ak128mc106_gp_dim/dspic33ak128mc106_gp_dim.X/bsp/pot.c

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,18 @@
2020
*/
2121

2222
#include "pot.h"
23+
#include "../mcc_generated_files/adc/adc1.h"
2324
#include <xc.h>
2425

2526
void POT_Initialize(void)
2627
{
27-
// In this example channel 4 will be used.
28-
// Oversampling conversion mode.
29-
AD1CH1CONbits.MODE = 3;
30-
// Set number of conversions accumulated to 256.
31-
AD1CH1CONbits.ACCNUM = 2;
32-
// The oversampling if started cannot be interrupted
33-
// by a high priority channels conversion requests.
34-
AD1CH1CONbits.ACCBRST = 1;
3528

36-
// Software trigger will start a conversion.
37-
AD1CH1CONbits.TRG1SRC = 1;
38-
39-
// Re-trigger back to back.
40-
AD1CH1CONbits.TRG2SRC = 2;
41-
42-
// Use a single ended input.
43-
AD1CH1CONbits.DIFF = 0;
44-
// Select the AN6 analog positive input/pin for the signal.
45-
AD1CH1CONbits.PINSEL = 6;
46-
// Select the GND as negative input/pin for the signal.
47-
AD1CH1CONbits.NINSEL = 0;
48-
// Select signal sampling time (6.5 TADs = 81 nS).
49-
AD1CH1CONbits.SAMC = 3;
50-
// Set ADC to RUN mode.
51-
AD1CONbits.MODE = 2;
52-
// Enable ADC.
53-
AD1CONbits.ON = 1;
54-
55-
// Wait when ADC will be ready/calibrated.
56-
while(AD1CONbits.ADRDY == 0)
57-
{
58-
}
5929
}
6030

6131
uint16_t POT_Read(void)
6232
{
63-
// Trigger channel #1 in software and wait for the result.
64-
AD1SWTRGbits.CH1TRG = 1;
65-
// Wait for a conversion ready flag.
66-
while(AD1STATbits.CH1RDY == 0)
67-
{
68-
}
69-
70-
// Read result. It will clear the conversion ready flag.
71-
// Convert to 16-bit value.
72-
return AD1CH1DATA<<1;
33+
ADC1.SoftwareTriggerEnable();
34+
return ADC1.ConversionResultGet(ADC1_Channel0);
7335
}
7436

7537
const struct POT pot =

0 commit comments

Comments
 (0)