Skip to content

Commit 0d40034

Browse files
Usha Gsaikprasad
authored andcommitted
MPAE-18367 Gnerated the firmware using latest tools
1 parent f663c10 commit 0d40034

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

+2306
-1383
lines changed

pic16f15244-uart-i2c-bridge-i2c-client1-mplab-mcc.X/application.c renamed to pic16f15244-uart-i2c-bridge-client1-mplab-mcc.X/application.c

Lines changed: 85 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
* File: application.c
33
* Author: I51005
44
*
5-
* Created on August 3, 2024, 2:38 PM
5+
* Created on June 18, 2025, 8:43 PM
66
*/
77

8+
89
#include "mcc_generated_files/system/system.h"
910
#include "mcc_generated_files/adc/adc.h"
1011
#include "string.h"
@@ -22,36 +23,33 @@
2223
* @param void
2324
* @return void
2425
******************************************************************************/
25-
void Application(void)
26-
{
27-
//To read the sensor data periodically for every 5 sec
28-
if(timerInterruptFlag == SET)
29-
{
30-
#ifdef DEBUG
31-
EUSART1_SendString("Timer WakeUP\n"); // only for debug
32-
#endif
33-
Sensor1_DataProcessing();
34-
timerInterruptFlag = 0;
35-
}
36-
else if(SSP1STATbits.I2C_START)
37-
{
38-
#ifdef DEBUG
39-
EUSART1_SendString(" I2C WakeUP\n"); //only for debug
40-
#endif
41-
if(i2cRdDataIndex >= 2)
42-
{
43-
CLOCK_STRETCH_ENABLE();
44-
i2cRxDataLength = i2cRdData[ONE];
45-
i2cRxSensorRegisterAddress = i2cRdData[ZERO];
46-
SensorDataRegisterRead(i2cRxSensorRegisterAddress,i2cRxDataLength);
47-
CLOCK_STRETCH_DISABLE();
48-
DELAY_FUNCTION();
49-
i2cRdDataIndex = 0;
50-
}
51-
}
52-
else
53-
{
54-
// SLEEP();
26+
void Application(void) {
27+
//To read the sensor data periodically for every 5 sec
28+
if (timerInterruptFlag == SET) {
29+
#ifdef DEBUG
30+
printf("Timer WakeUP\n"); // only for debug
31+
__delay_ms(10);
32+
#endif
33+
Sensor1_DataProcessing();
34+
timerInterruptFlag = 0;
35+
} else if (SSP1STATbits.I2C_START) {
36+
#ifdef DEBUG
37+
printf(" I2C WakeUP\n"); //only for debug
38+
__delay_ms(10);
39+
#endif
40+
if (i2cRdDataIndex >= 2) {
41+
printf(" I2C Data\n"); //only for debug
42+
__delay_ms(10);
43+
CLOCK_STRETCH_ENABLE();
44+
i2cRxDataLength = i2cRdData[ONE];
45+
i2cRxSensorRegisterAddress = i2cRdData[ZERO];
46+
SensorDataRegisterRead((uint8_t*) i2cRxSensorRegisterAddress, i2cRxDataLength);
47+
CLOCK_STRETCH_DISABLE();
48+
DELAY_FUNCTION();
49+
i2cRdDataIndex = 0;
50+
}
51+
} else {
52+
SLEEP();
5553
}
5654
}
5755

@@ -63,10 +61,8 @@ void Application(void)
6361
* @param *str - to send a sequence of strings on terminal window
6462
* @return void
6563
******************************************************************************/
66-
void EUSART1_SendString(const char *str)
67-
{
68-
for(uint8_t index = 0; index < strlen(str); index++)
69-
{
64+
void EUSART1_SendString(const char *str) {
65+
for (uint8_t index = 0; index < strlen(str); index++) {
7066
EUSART1_Write(str[index]);
7167
}
7268
}
@@ -80,30 +76,31 @@ void EUSART1_SendString(const char *str)
8076
* @param void
8177
* @return void
8278
******************************************************************************/
83-
void Sensor1_DataProcessing(void)
84-
{
79+
void Sensor1_DataProcessing(void) {
8580
uint16_t adcBuffer = 0;
8681
uint16_t adcSamples = 0;
8782
uint16_t samplesAverage = 0;
8883
float dataBuffer = 0;
8984
uint8_t samplesCount;
90-
91-
for (samplesCount = 0; samplesCount < ADC_SAMPLES; samplesCount++)
92-
{
93-
adcBuffer = ADC_GetConversion(channel_ANC4);
85+
86+
for (samplesCount = 0; samplesCount < ADC_SAMPLES; samplesCount++) {
87+
adcBuffer = ADC_ChannelSelectAndConvert(ADC_CHANNEL_ANC4);
88+
9489
adcSamples += adcBuffer;
9590
}
96-
97-
if(samplesCount >= ADC_SAMPLES)
98-
{
99-
samplesAverage = (adcSamples >> RIGHTSHIFT_COUNT);
100-
dataBuffer = (samplesAverage * VDD)/ ADC_MAX_VALUE;
101-
phValue = (uint8_t)(CONSTANT * dataBuffer);
102-
sensor_Data_Register[0] = phValue;
91+
92+
if (samplesCount >= ADC_SAMPLES) {
93+
samplesAverage = (adcSamples >> RIGHTSHIFT_COUNT);
94+
dataBuffer = (samplesAverage * VDD) / ADC_MAX_VALUE;
95+
phValue = (uint8_t) (CONSTANT * dataBuffer);
96+
sensor_Data_Register[0] = phValue;
97+
printf("ph value: %d", phValue);
98+
__delay_ms(10);
10399
adcSamples = 0;
104-
samplesCount = 0;
100+
samplesCount = 0;
105101
adcBuffer = 0;
106-
}
102+
103+
}
107104
}
108105

109106
/*******************************************************************************
@@ -116,16 +113,14 @@ void Sensor1_DataProcessing(void)
116113
* host device
117114
* @return void
118115
******************************************************************************/
119-
void SensorDataRegisterRead(const uint8_t *sensorRevdData, uint8_t dataLength)
120-
{
121-
uint8_t index = 0;
122-
116+
void SensorDataRegisterRead(uint8_t *sensorRevdData, uint8_t dataLength) {
117+
uint8_t index = 0;
118+
123119
//Clears the i2cWrData array
124-
memset((uint8_t*)i2cWrData, 0 , sizeof(i2cWrData));
125-
126-
for(index = 0;index < dataLength;index++)
127-
{
128-
i2cWrData[index] = *(sensorRevdData+index);
120+
memset((uint8_t*) i2cWrData, 0, sizeof (i2cWrData));
121+
122+
for (index = 0; index < dataLength; index++) {
123+
i2cWrData[index] = *(sensorRevdData + index);
129124
}
130125
}
131126

@@ -137,51 +132,38 @@ void SensorDataRegisterRead(const uint8_t *sensorRevdData, uint8_t dataLength)
137132
* @param void
138133
* @return void
139134
******************************************************************************/
140-
bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event)
141-
{
142-
switch (event)
143-
{
144-
case I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH:
145-
146-
if (I2C1_TransferDirGet() == I2C_CLIENT_TRANSFER_DIR_WRITE)
147-
{
148-
if (I2C1_ReadAddr() == CLIENT_7_BIT_ADDR)
149-
{
150-
currentClient = CLIENT_7_BIT_ADDR;
151-
152-
}
153-
}
154-
break;
135+
bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event) {
136+
switch (event) {
137+
case I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH:
155138

156-
case I2C_CLIENT_TRANSFER_EVENT_RX_READY:
157-
if(i2cRdDataIndex >= LENGTH)
158-
{
159-
i2cRdDataIndex = 0;
139+
if (I2C1_TransferDirGet() == I2C_CLIENT_TRANSFER_DIR_WRITE) {
140+
if (I2C1_ReadAddr() == CLIENT_7_BIT_ADDR) {
141+
currentClient = CLIENT_7_BIT_ADDR;
142+
143+
}
160144
}
161-
else
162-
{
145+
break;
146+
147+
case I2C_CLIENT_TRANSFER_EVENT_RX_READY:
148+
if (i2cRdDataIndex >= LENGTH) {
149+
i2cRdDataIndex = 0;
150+
} else {
163151
i2cRdData[i2cRdDataIndex++] = I2C1_ReadByte();
164-
}
165-
break;
166-
case I2C_CLIENT_TRANSFER_EVENT_TX_READY:
167-
if(i2cWrDataIndex >= ONE_BYTELENGTH)
168-
{
169-
i2cWrDataIndex = 0;
170152
}
171-
else
172-
{
173-
I2C1_WriteByte(i2cWrData[i2cWrDataIndex++]);
174-
printf("%d", i2cWrData[i2cWrDataIndex]);
153+
break;
154+
case I2C_CLIENT_TRANSFER_EVENT_TX_READY:
155+
if (i2cWrDataIndex >= ONE_BYTELENGTH) {
156+
i2cWrDataIndex = 0;
175157
}
176-
177-
break;
178-
179-
case I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED:
180-
i2cRdDataIndex = 0x00;
181-
break;
182-
183-
default:
184-
break;
158+
if (currentClient == CLIENT_7_BIT_ADDR) {
159+
I2C1_Client.WriteByte(i2cWrData[i2cWrDataIndex++]);
160+
}
161+
break;
162+
case I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED:
163+
164+
break;
165+
default:
166+
break;
185167
}
186168
return true;
187169
}
@@ -194,12 +176,10 @@ bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event)
194176
* @param void
195177
* @return void
196178
******************************************************************************/
197-
void TimerInterruptHandler(void)
198-
{
199-
timerInterruptFlag= 1;
200-
}
179+
void TimerInterruptHandler(void) {
180+
timerInterruptFlag = 1;
181+
}
201182

202183
/**
203184
End of File
204-
*/
205-
185+
*/

pic16f15244-uart-i2c-bridge-i2c-client1-mplab-mcc.X/application.h renamed to pic16f15244-uart-i2c-bridge-client1-mplab-mcc.X/application.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ void I2C_ReadInterruptHandler(void);
8989
void TimerInterruptHandler(void);
9090
void Sensor1_DataProcessing(void);
9191
void EUSART1_SendString(const char *str);
92-
void SensorDataRegisterRead(const uint8_t *sensorRevdData, uint8_t dataLength);
92+
void SensorDataRegisterRead(uint8_t *sensorRevdData, uint8_t dataLength);
9393
bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event);
94+
95+
96+
9497
#ifdef __cplusplus
9598
extern "C" {
9699
#endif /* __cplusplus */

pic16f15244-uart-i2c-bridge-i2c-client1-mplab-mcc.X/main.c renamed to pic16f15244-uart-i2c-bridge-client1-mplab-mcc.X/main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
/*
16-
© [2024] Microchip Technology Inc. and its subsidiaries.
16+
© [2025] Microchip Technology Inc. and its subsidiaries.
1717
1818
Subject to your compliance with these terms, you may use Microchip
1919
software and any derivatives exclusively with Microchip products.
@@ -35,6 +35,7 @@
3535
#include "mcc_generated_files/system/system.h"
3636
#include "application.h"
3737

38+
3839
/*
3940
Main application
4041
*/
@@ -58,12 +59,13 @@ int main(void)
5859
// Disable the Peripheral Interrupts
5960
//INTERRUPT_PeripheralInterruptDisable();
6061

61-
Timer0_OverflowCallbackRegister(TimerInterruptHandler);
62+
TMR0_PeriodMatchCallbackRegister(TimerInterruptHandler);
6263
I2C1_CallbackRegister(I2C_ClientInterruptHandler);
6364
LED_SetLow();
64-
6565
while(1)
6666
{
6767
Application();
68-
}
68+
69+
}
70+
6971
}
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
# This file has been autogenerated by MPLAB Code Configurator. Please do not edit this file.
22

33
manifest_file_version: 1.0.0
4-
project: pic16f15244-usart-i2c-bridge-client1-mplab-mcc
5-
creation_date: 2024-08-22T12:05:49.431+05:30[Asia/Calcutta]
6-
operating_system: Windows 10
4+
project: pic16f15244-uart-i2c-bridge-client1-mplab-mcc
5+
creation_date: 2025-06-26T12:11:33.227+05:30[Asia/Calcutta]
6+
operating_system: Windows 11
77
mcc_mode: IDE
8-
mcc_mode_version: v6.20
8+
mcc_mode_version: v6.25
99
device_name: PIC16F15244
10-
compiler: XC8 2.50
11-
mcc_version: 5.5.1
12-
mcc_core_version: 5.7.1
13-
content_manager_version: 5.0.1
10+
compiler: XC8 3.00
11+
mcc_version: 5.6.2
12+
mcc_core_version: 5.8.2
13+
content_manager_version: 6.0.1
1414
is_mcc_offline: false
15-
is_using_prerelease_versions: true
16-
mcc_content_registries: https://registry.npmjs.org/,https://artifacts.microchip.com/artifactory/api/npm/npm/
17-
device_library: {library_class: com.microchip.mcc.melody.Library, name: Melody, version: 2.7.1}
18-
packs: {name: PIC16F1xxxx_DFP, version: 1.26.395}
15+
is_using_prerelease_versions: false
16+
mcc_content_registries: https://registry.npmjs.org/,
17+
device_library: {library_class: com.microchip.mcc.melody.Library, name: Melody, version: 2.9.1}
18+
packs: {name: N/A, version: N/A}
1919
modules:
20-
- {name: '@mchp-mcc/i2c-client-driver', type: MELODY, version: 2.0.4}
20+
- {name: '@mchp-mcc/i2c-client-driver', type: MELODY, version: 2.1.0}
2121
- {name: '@mchp-mcc/main-manager', type: MELODY, version: 3.1.2}
22-
- {name: '@mchp-mcc/pic-8bit', type: MELODY, version: 5.28.3-test.1}
22+
- {name: '@mchp-mcc/melody', type: CLASSIC, version: 2.9.1}
23+
- {name: '@mchp-mcc/pic-8bit', type: MELODY, version: 5.29.1}
2324
- {name: '@mchp-mcc/pic16-configuration-bits-v2', type: MELODY, version: 4.1.3}
24-
- {name: '@mchp-mcc/pic16-pin-manager', type: MELODY, version: 3.6.1}
25-
- {name: '@mchp-mcc/pin-content-processor', type: MELODY, version: 3.8.0}
26-
- {name: '@mchp-mcc/scf-pic8-adc-v1', type: MELODY, version: 3.0.10}
27-
- {name: '@mchp-mcc/scf-pic8-eusart-v1', type: MELODY, version: 7.1.6}
28-
- {name: '@mchp-mcc/scf-pic8-interrupt-v2', type: MELODY, version: 5.2.11}
29-
- {name: '@mchp-mcc/scf-pic8-mssp-v1', type: MELODY, version: 7.0.1}
25+
- {name: '@mchp-mcc/pic16-pin-manager', type: MELODY, version: 3.6.3}
26+
- {name: '@mchp-mcc/pin-content-processor', type: MELODY, version: 3.10.0}
27+
- {name: '@mchp-mcc/scf-pic8-adc-v1', type: MELODY, version: 4.0.0}
28+
- {name: '@mchp-mcc/scf-pic8-eusart-v1', type: MELODY, version: 7.1.7}
29+
- {name: '@mchp-mcc/scf-pic8-interrupt-v2', type: MELODY, version: 5.2.12}
30+
- {name: '@mchp-mcc/scf-pic8-mssp-v1', type: MELODY, version: 7.0.3}
3031
- {name: '@mchp-mcc/scf-pic8-osc-v2', type: MELODY, version: 4.2.2}
31-
- {name: '@mchp-mcc/scf-pic8-tmr0-v1', type: MELODY, version: 4.0.13}
32+
- {name: '@mchp-mcc/scf-pic8-tmr0-v1', type: MELODY, version: 5.1.0}
3233
- {name: '@mchp-mcc/uart-driver', type: MELODY, version: 1.10.2}

0 commit comments

Comments
 (0)