Skip to content

Commit 4bb6eea

Browse files
Usha Gsaikprasad
authored andcommitted
MPAE-18347 Generated the firmware with latest tools
1 parent 0c4e8d3 commit 4bb6eea

Some content is hidden

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

43 files changed

+2636
-1525
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
/*
2+
* File: application.c
3+
* Author: I51005
4+
*
5+
* Created on June 19, 2025, 4:34 PM
6+
*/
7+
8+
19
#include "mcc_generated_files/system/system.h"
210
#include "mcc_generated_files/adc/adc.h"
311
#include "application.h"
412
#include "string.h"
513
#include "stdlib.h"
614
#include "stdio.h"
715

8-
916
/*******************************************************************************
1017
* void Application(void)
1118
*
@@ -16,40 +23,32 @@
1623
* @param void
1724
* @return void
1825
******************************************************************************/
19-
void Application(void)
20-
{
21-
//To read the sensor data periodically for every 5 sec
22-
if(timerInterruptFlag == SET)
23-
{
26+
void Application(void) {
27+
//To read the sensor data periodically for every 5 sec
28+
if (timerInterruptFlag == SET) {
2429
#ifdef DEBUG
25-
printf("Timer WakeUP\n"); // only for debug
30+
EUSART1_SendString("Timer WakeUP\n"); // only for debug
2631
#endif
2732
Sensor2_DataProcessing(); //Read Analog Sensor 2 and calibration
2833
Sensor3_DataProcessing(); //Read Analog Sensor 3 and calibration
2934
timerInterruptFlag = CLEAR;
30-
}
31-
else if(SSP1STATbits.I2C_START)
32-
{
35+
} else if (SSP1STATbits.I2C_START) {
3336
#ifdef DEBUG
34-
printf(" I2C WakeUP\n"); //only for debug
37+
EUSART1_SendString(" I2C WakeUP\n"); //only for debug
3538
#endif
36-
if(i2cRdDataIndex >= LENGTH)
37-
{
38-
CLOCK_STRETCH_ENABLE();
39+
if (i2cRdDataIndex >= LENGTH) {
40+
CLOCK_STRETCH_ENABLE();
3941
i2cRxDataLength = i2cRdData[ONE];
4042
i2cRxSensorRegisterAddress = i2cRdData[ZERO];
41-
SensorDataRegisterRead(i2cRxSensorRegisterAddress,i2cRxDataLength);
42-
i2cWrDataIndex = 0;
43-
CLOCK_STRETCH_DISABLE();
43+
SensorDataRegisterRead((uint8_t*) i2cRxSensorRegisterAddress, i2cRxDataLength);
44+
CLOCK_STRETCH_DISABLE();
4445
i2cRdDataIndex = ZERO;
4546
DELAY_FUNCTION();
4647
}
47-
}
48-
else
49-
{
48+
} else {
5049
SLEEP();
5150
}
52-
51+
5352
}
5453

5554
/*******************************************************************************
@@ -60,10 +59,8 @@ void Application(void)
6059
* @param *str - to send a sequence of strings on terminal window
6160
* @return void
6261
******************************************************************************/
63-
void EUSART1_SendString(const char *str)
64-
{
65-
for(uint8_t index = 0; index < strlen(str); index++)
66-
{
62+
void EUSART1_SendString(const char *str) {
63+
for (uint8_t index = 0; index < strlen(str); index++) {
6764
EUSART1_Write(str[index]);
6865
}
6966
}
@@ -78,16 +75,14 @@ void EUSART1_SendString(const char *str)
7875
* host device
7976
* @return void
8077
******************************************************************************/
81-
void SensorDataRegisterRead(uint8_t *sensorRevdData, uint8_t dataLength)
82-
{
78+
void SensorDataRegisterRead(uint8_t *sensorRevdData, uint8_t dataLength) {
8379
uint8_t index = 0;
84-
80+
8581
//Clears the i2cWrData array
86-
memset((uint8_t*)i2cWrData, 0 , sizeof(i2cWrData));
87-
88-
for( index = 0;index < dataLength;index++)
89-
{
90-
i2cWrData[index] = *(sensorRevdData+index);
82+
memset((uint8_t*) i2cWrData, 0, sizeof (i2cWrData));
83+
84+
for (index = 0; index < dataLength; index++) {
85+
i2cWrData[index] = *(sensorRevdData + index);
9186
}
9287
}
9388

@@ -101,19 +96,17 @@ void SensorDataRegisterRead(uint8_t *sensorRevdData, uint8_t dataLength)
10196
* @param void
10297
* @return void
10398
******************************************************************************/
104-
void Sensor2_DataProcessing(void)
105-
{
99+
void Sensor2_DataProcessing(void) {
106100
uint16_t adcBuffer = 0;
107101
float dataBuffer = 0;
108102
float buffer = 0;
109-
110-
adcBuffer = ADC_GetConversion(channel_ANB7);
111-
dataBuffer = (((float)adcBuffer/ADC_MAX_VALUE )* VDD);
112-
buffer = ((dataBuffer / VDD) * TEMP_CONSTANT);
113-
temp_Value = (uint8_t)(TEMP_CONSTANT1 + buffer);
114-
sensor_Data_Register[ZERO]= temp_Value;
115-
116103

104+
adcBuffer = ADC_ChannelSelectAndConvert(ADC_CHANNEL_ANB7);
105+
dataBuffer = (((float) adcBuffer / ADC_MAX_VALUE) * VDD);
106+
buffer = ((dataBuffer / VDD) * TEMP_CONSTANT);
107+
temp_Value = (uint8_t) (TEMP_CONSTANT1 + buffer);
108+
sensor_Data_Register[ZERO] = temp_Value;
109+
printf("Temperature value: %d", temp_Value);
117110
}
118111

119112
/*******************************************************************************
@@ -126,18 +119,17 @@ void Sensor2_DataProcessing(void)
126119
* @param void
127120
* @return void
128121
******************************************************************************/
129-
void Sensor3_DataProcessing(void)
130-
{
122+
void Sensor3_DataProcessing(void) {
131123
uint16_t adcBuffer = 0;
132124
float dataBuffer = 0;
133-
float buffer = 0;
134-
135-
adcBuffer = ADC_GetConversion(channel_ANC4);
125+
float buffer = 0;
126+
127+
adcBuffer = ADC_ChannelSelectAndConvert(ADC_CHANNEL_ANC4);
136128
dataBuffer = ADC_MAX_VALUE - adcBuffer;
137-
buffer = (dataBuffer / (ADC_MAX_VALUE-1));
138-
soilSensor_Value = (uint8_t)(buffer * 100);
129+
buffer = (dataBuffer / (ADC_MAX_VALUE - 1));
130+
soilSensor_Value = (uint8_t) (buffer * 100);
139131
sensor_Data_Register[ONE] = soilSensor_Value;
140-
132+
printf("Soil Sensor value: %d", soilSensor_Value);
141133
}
142134

143135
/*******************************************************************************
@@ -148,10 +140,9 @@ void Sensor3_DataProcessing(void)
148140
* @param void
149141
* @return void
150142
******************************************************************************/
151-
void TimerInterruptHandler(void)
152-
{
143+
void TimerInterruptHandler(void) {
153144
timerInterruptFlag = SET;
154-
}
145+
}
155146

156147
/*******************************************************************************
157148
* bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event)
@@ -161,45 +152,50 @@ void TimerInterruptHandler(void)
161152
* @param void
162153
* @return void
163154
******************************************************************************/
164-
bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event)
165-
{
166-
switch (event)
167-
{
168-
case I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH:
169-
170-
if (I2C1_TransferDirGet() == I2C_CLIENT_TRANSFER_DIR_WRITE)
171-
{
172-
if (I2C1_ReadAddr() == CLIENT2_7_BIT_ADDR)
173-
{
174-
currentClient = CLIENT2_7_BIT_ADDR;
155+
bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event) {
156+
157+
switch (event) {
158+
case I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH:
159+
160+
if (I2C1_TransferDirGet() == I2C_CLIENT_TRANSFER_DIR_WRITE) {
161+
if (I2C1_ReadAddr() == CLIENT2_7_BIT_ADDR) {
162+
currentClient = CLIENT2_7_BIT_ADDR;
163+
}
175164
}
176-
}
177-
break;
165+
break;
178166

179-
case I2C_CLIENT_TRANSFER_EVENT_RX_READY:
180-
if(currentClient == CLIENT2_7_BIT_ADDR)
181-
{
167+
case I2C_CLIENT_TRANSFER_EVENT_RX_READY:
168+
if (i2cRdDataIndex >= LENGTH) {
169+
i2cRdDataIndex = 0;
170+
}
171+
if (currentClient == CLIENT2_7_BIT_ADDR) {
182172
i2cRdData[i2cRdDataIndex++] = I2C1_ReadByte();
183-
}
184-
break;
185-
case I2C_CLIENT_TRANSFER_EVENT_TX_READY:
186-
I2C1_WriteByte(i2cWrData[index++]);
187-
if(index > i2cRxDataLength)
188-
{
189-
index = 0;
190-
}
191-
break;
192-
193-
case I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED:
194-
//i2cRdDataIndex = 0x00;
195-
break;
196-
197-
default:
198-
break;
173+
174+
}
175+
break;
176+
case I2C_CLIENT_TRANSFER_EVENT_TX_READY:
177+
if (currentClient == CLIENT2_7_BIT_ADDR) {
178+
if (i2cWrDataIndex < i2cRxDataLength) {
179+
I2C1_WriteByte(i2cWrData[i2cWrDataIndex++]);
180+
}
181+
}
182+
183+
if (i2cWrDataIndex >= i2cRxDataLength) {
184+
i2cWrDataIndex = 0;
185+
i2cRxDataLength = 0;
186+
}
187+
break;
188+
189+
case I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED:
190+
191+
break;
192+
193+
default:
194+
break;
199195
}
200196
return true;
201197
}
202198

203199
/**
204200
End of File
205-
*/
201+
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ client_t currentClient;
6868
* File Global variables
6969
* **********************************************************
7070
**/
71-
uint8_t sensor_Data_Register[2] __at(0x76);
71+
uint8_t sensor_Data_Register[LENGTH] __at(0x76);
7272
//uint8_t sensor2_Data_Register_Adress[LENGTH] = {0x76};
7373
//uint8_t sensor3_Data_Register_Adress[LENGTH] = {0x77};
7474
uint8_t i2cWrData[LENGTH];
@@ -80,7 +80,6 @@ uint8_t temp_Value;
8080
uint8_t i2cRxDataLength;
8181
uint8_t i2cRxSensorRegisterAddress;
8282
volatile uint8_t timerInterruptFlag = SET;
83-
volatile uint8_t index = CLEAR;
8483
/**
8584
* **********************************************************
8685
* Function declarations
@@ -95,6 +94,7 @@ void Sensor3_DataProcessing(void);
9594
void EUSART1_SendString(const char *str);
9695
void SensorDataRegisterRead(uint8_t *sensorRevdData, uint8_t dataLength);
9796
bool I2C_ClientInterruptHandler(i2c_client_transfer_event_t event);
97+
9898
#ifdef __cplusplus
9999
extern "C" {
100100
#endif /* __cplusplus */

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

Lines changed: 7 additions & 3 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.
@@ -54,12 +54,16 @@ int main(void)
5454
// Enable the Peripheral Interrupts
5555
INTERRUPT_PeripheralInterruptEnable();
5656

57-
Timer0_OverflowCallbackRegister(TimerInterruptHandler);
57+
// Disable the Peripheral Interrupts
58+
//INTERRUPT_PeripheralInterruptDisable();
59+
60+
61+
TMR0_PeriodMatchCallbackRegister(TimerInterruptHandler);
5862
I2C1_CallbackRegister(I2C_ClientInterruptHandler);
5963
LED_SetLow();
6064

6165
while(1)
6266
{
6367
Application();
64-
}
68+
}
6569
}
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
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-uart-i2c-bridge-i2c-client2-mplab-mcc
5-
creation_date: 2024-08-22T09:56:58.160+05:30[Asia/Calcutta]
6-
operating_system: Windows 10
4+
project: pic16f15244-uart-i2c-bridge-client2-mplab-mcc
5+
creation_date: 2025-06-25T15:01:52.241+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.2-dev.3}
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.2}
22+
- {name: '@mchp-mcc/pic-8bit', type: MELODY, version: 5.29.2-dev.1}
2323
- {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}
24+
- {name: '@mchp-mcc/pic16-pin-manager', type: MELODY, version: 3.6.3}
25+
- {name: '@mchp-mcc/pin-content-processor', type: MELODY, version: 3.10.0}
26+
- {name: '@mchp-mcc/scf-pic8-adc-v1', type: MELODY, version: 4.0.0}
27+
- {name: '@mchp-mcc/scf-pic8-eusart-v1', type: MELODY, version: 7.1.7}
28+
- {name: '@mchp-mcc/scf-pic8-interrupt-v2', type: MELODY, version: 5.2.12}
29+
- {name: '@mchp-mcc/scf-pic8-mssp-v1', type: MELODY, version: 7.0.3}
3030
- {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}
31+
- {name: '@mchp-mcc/scf-pic8-tmr0-v1', type: MELODY, version: 5.1.0}
3232
- {name: '@mchp-mcc/uart-driver', type: MELODY, version: 1.10.2}

0 commit comments

Comments
 (0)