This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
i am using TMS320F2812 processor and the ccsV4. i want to generate sine triangle PWM in which sine wave is generated using the some array of of numbers(taken 1000 instantaneous values for one cycle and converted as digital values using the formula (4095* instantaneous value/3)). i have written the code but it is giving the error. here i am attaching the code. please help me.
#define fc 2000; #define fs 50; #define ma 1; main() { // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the DSP281x_SysCtrl.c file. InitSysCtrl(); // Step 2. Initalize GPIO: // This example function is found in the DSP281x_Gpio.c file and // illustrates how to set the GPIO to it's default state. // InitGpio(); // Skipped for this example EALLOW; // Enable PWM pins GpioMuxRegs.GPAMUX.all = 0x00FF; // EVA PWM 1-6 pins GpioMuxRegs.GPBMUX.all = 0x00FF; // EVB PWM 7-12 pins EDIS; // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the DSP281x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP281x_DefaultIsr.c. // This function is found in DSP281x_PieVect.c. InitPieVectTable(); // Step 4. Initialize all the Device Peripherals: // This function is found in DSP281x_InitPeripherals.c // InitPeripherals(); // Not required for this example init_pwm_isr(); // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.T1UFINT = &init_pwm_isr; EDIS; // This is needed to disable write to EALLOW protected registers // Enable PIE group 2 interrupt 4 for T1PINT and interrupt 6 for T1UFINT PieCtrlRegs.PIEIER2.all = 0x0028; // Enable PIE group 4 interrupt 4 for T3PINT and interrupt 6 for T3UFINT PieCtrlRegs.PIEIER4.all = 0x0028; // Enable CPU INT2 for T1PINT and T1UFINT , INT4 for T3PINT and T3UFINT IER |= (M_INT2 | M_INT4); EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM for(;;); } void init_PWM_isr() { int i; float j,k,l; int a[]= //A-phase sine wave { 0, 9, 17, 26, 34, 43, 51, 60, 69, 77, 86, 94, 103, 111, 120, 128, 137, 146, 154, 163, 171, 180, 188, 197, 205, 213, 222, 230, 239, 247, 256, 264, 273, 281, 289, 298, 306, 314, 323, 331, 339, 348, 356, 364, 373, 381, 389, 397, 405, 414, 422, 430, 438, 446, 454, 462, 470, 478, 486, 495, 502, 511, 518, 526, 534, 542, 550, 558, 566, 573, 581, 589, 597, 604, 612, 620, 627, 635, 643, 650, 658, 665, 673, 680, 687, 695, 702, 710, 717, 724, 731, 739, 746, 753, 760, 767, 774, 781, 788, 795, 802, 809, 816, 823, 830, 837, 843, 850, 857, 863, 870, 877, 883, 890, 896, 903, 909, 916, 922, 928, 934, 941, 947, 953, 959, 965, 971, 977, 983, 989, 995, 1001, 1007, 1012, 1018, 1024, 1030, 1035, 1041, 1046, 1052, 1057, 1063, 1068, 1073, 1079, 1084, 1089, 1094, 1099, 1104, 1109, 1114, 1119, 1124, 1129, 1134, 1139, 1143, 1148, 1152, 1157, 1162, 1166, 1170, 1175, 1179, 1184, 1188, 1192, 1196, 1200, 1204, 1208, 1212, 1216, 1220, 1224, 1228, 1231, 1235, 1239, 1242, 1246, 1249, 1253, 1256, 1259, 1263, 1266, 1269, 1272, 1275, 1278, 1281, 1284, 1287, 1290, 1293, 1296, 1298, 1301, 1303, 1306, 1308, 1311, 1313, 1315, 1318, 1320, 1322, 1324, 1326, 1328, 1330, 1332, 1334, 1336, 1338, 1339, 1341, 1342, 1344, 1345, 1347, 1348, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1360, 1361, 1362, 1362, 1363, 1363, 1364, 1364, 1364, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1364, 1364, 1364, 1363, 1363, 1362, 1362, 1361, 1360, 1360, 1359, 1358, 1357, 1356, 1355, 1354, 1353, 1352, 1351, 1350, 1348, 1347, 1345, 1344, 1342, 1341, 1339, 1338, 1336, 1334, 1332, 1330, 1328, 1326, 1324, 1322, 1320, 1318, 1315, 1313, 1311, 1308, 1306, 1303, 1301, 1298, 1296, 1293, 1290, 1287, 1284, 1281, 1278, 1275, 1272, 1269, 1266, 1263, 1259, 1256, 1253, 1249, 1246, 1242, 1239, 1235, 1231, 1228, 1224, 1220, 1216, 1212, 1208, 1204, 1200, 1196, 1192, 1188, 1184, 1179, 1175, 1170, 1166, 1162, 1157, 1152, 1148, 1143, 1139, 1134, 1129, 1124, 1119, 1114, 1109, 1104, 1099, 1094, 1089, 1084, 1079, 1073, 1068, 1063, 1057, 1052, 1046, 1041, 1035, 1030, 1024, 1018, 1012, 1007, 1001, 995, 989, 983, 977, 971, 965, 959, 953, 947, 941, 934, 928, 922, 916, 909, 903, 896, 890, 883, 877, 870, 863, 857, 850, 843, 837, 830, 823, 816, 809, 802, 795, 788, 781, 774, 767, 760, 753, 746, 739, 731, 724, 717, 710, 702, 695, 687, 680, 673, 665, 658, 650, 643, 635, 627, 620, 612, 604, 597, 589, 581, 573, 566, 558, 550, 542, 534, 526, 518, 511, 502, 495, 486, 478, 470, 462, 454, 446, 438, 430, 422, 414, 405, 397, 389, 381, 373, 364, 356, 348, 339, 331, 323, 314, 306, 298, 289, 281, 273, 264, 256, 247, 239, 230, 222, 213, 205, 197, 188, 180, 171, 163, 154, 146, 137, 128, 120, 111, 103, 94, 86, 77, 69, 60, 51, 43, 34, 26, 17, 9, 0, -9, -17, -26, -34, -43, -51, -60, -69, -77, -86, -94, -103, -111, -120, -128, -137, -146, -154, -163, -171, -180, -188, -197, -205, -213, -222, -230, -239, -247, -256, -264, -273, -281, -289, -298, -306, -314, -323, -331, -339, -348, -356, -364, -373, -381, -389, -397, -405, -414, -422, -430, -438, -446, -454, -462, -470, -478, -486, -495, -502, -511, -518, -526, -534, -542, -550, -558, -566, -573, -581, -589, -597, -604, -612, -620, -627, -635, -643, -650, -658, -665, -673, -680, -687, -695, -702, -710, -717, -724, -731, -739, -746, -753, -760, -767, -774, -781, -788, -795, -802, -809, -816, -823, -830, -837, -843, -850, -857, -863, -870, -877, -883, -890, -896, -903, -909, -916, -922, -928, -934, -941, -947, -953, -959, -965, -971, -977, -983, -989, -995, -1001, -1007, -1012, -1018, -1024, -1030, -1035, -1041, -1046, -1052, -1057, -1063, -1068, -1073, -1079, -1084, -1089, -1094, -1099, -1104, -1109, -1114, -1119, -1124, -1129, -1134, -1139, -1143, -1148, -1152, -1157, -1162, -1166, -1170, -1175, -1179, -1184, -1188, -1192, -1196, -1200, -1204, -1208, -1212, -1216, -1220, -1224, -1228, -1231, -1235, -1239, -1242, -1246, -1249, -1253, -1256, -1259, -1263, -1266, -1269, -1272, -1275, -1278, -1281, -1284, -1287, -1290, -1293, -1296, -1298, -1301, -1303, -1306, -1308, -1311, -1313, -1315, -1318, -1320, -1322, -1324, -1326, -1328, -1330, -1332, -1334, -1336, -1338, -1339, -1341, -1342, -1344, -1345, -1347, -1348, -1350, -1351, -1352, -1353, -1354, -1355, -1356, -1357, -1358, -1359, -1360, -1360, -1361, -1362, -1362, -1363, -1363, -1364, -1364, -1364, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1364, -1364, -1364, -1363, -1363, -1362, -1362, -1361, -1360, -1360, -1359, -1358, -1357, -1356, -1355, -1354, -1353, -1352, -1351, -1350, -1348, -1347, -1345, -1344, -1342, -1341, -1339, -1338, -1336, -1334, -1332, -1330, -1328, -1326, -1324, -1322, -1320, -1318, -1315, -1313, -1311, -1308, -1306, -1303, -1301, -1298, -1296, -1293, -1290, -1287, -1284, -1281, -1278, -1275, -1272, -1269, -1266, -1263, -1259, -1256, -1253, -1249, -1246, -1242, -1239, -1235, -1231, -1228, -1224, -1220, -1216, -1212, -1208, -1204, -1200, -1196, -1192, -1188, -1184, -1179, -1175, -1170, -1166, -1162, -1157, -1152, -1148, -1143, -1139, -1134, -1129, -1124, -1119, -1114, -1109, -1104, -1099, -1094, -1089, -1084, -1079, -1073, -1068, -1063, -1057, -1052, -1046, -1041, -1035, -1030, -1024, -1018, -1012, -1007, -1001, -995, -989, -983, -977, -971, -965, -959, -953, -947, -941, -934, -928, -922, -916, -909, -903, -896, -890, -883, -877, -870, -863, -857, -850, -843, -837, -830, -823, -816, -809, -802, -795, -788, -781, -774, -767, -760, -753, -746, -739, -731, -724, -717, -710, -702, -695, -687, -680, -673, -665, -658, -650, -643, -635, -627, -620, -612, -604, -597, -589, -581, -573, -566, -558, -550, -542, -534, -526, -518, -511, -502, -495, -486, -478, -470, -462, -454, -446, -438, -430, -422, -414, -405, -397, -389, -381, -373, -364, -356, -348, -339, -331, -323, -314, -306, -298, -289, -281, -273, -264, -256, -247, -239, -230, -222, -213, -205, -197, -188, -180, -171, -163, -154, -146, -137, -128, -120, -111, -103, -94, -86, -77, -69, -60, -51, -43, -34, -26, -17, -9 } int b[]= //B-phase sine wave { 1182, 1178, 1173, 1169, 1165, 1160, 1156, 1151, 1146, 1142, 1137, 1132, 1127, 1122, 1118, 1113, 1108, 1103, 1098, 1092, 1087, 1082, 1077, 1072, 1066, 1061, 1055, 1050, 1044, 1039, 1033, 1028, 1022, 1016, 1011, 1005, 999, 993, 987, 981, 975, 969, 963, 957, 951, 945, 939, 932, 926, 920, 913, 907, 900, 894, 888, 881, 874, 868, 861, 855, 848, 841, 834, 828, 821, 814, 807, 800, 793, 786, 779, 772, 765, 758, 751, 743, 736, 729, 722, 714, 707, 700, 692, 685, 678, 670, 663, 655, 648, 640, 632, 625, 617, 609, 602, 594, 586, 579, 571, 563, 555, 547, 539, 532, 524, 516, 508, 500, 492, 484, 476, 468, 460, 452, 443, 435, 427, 419, 411, 403, 394, 386, 378, 370, 362, 353, 345, 337, 328, 320, 312, 303, 295, 287, 278, 270, 261, 253, 244, 236, 228, 219, 211, 202, 194, 185, 177, 168, 160, 151, 143, 134, 126, 117, 109, 100, 91, 83, 74, 66, 57, 49, 40, 31, 23, 14, 6, -3, -11, -20, -29, -37, -46, -54, -63, -71, -80, -89, -97, -106, -114, -123, -131, -140, -148, -157, -165, -174, -182, -191, -199, -208, -216, -225, -233, -242, -250, -259, -267, -275, -284, -292, -301, -309, -317, -326, -334, -342, -351, -359, -367, -375, -384, -392, -400, -408, -416, -425, -433, -441, -449, -457, -465, -473, -481, -489, -497, -505, -513, -521, -529, -537, -545, -553, -560, -568, -576, -584, -591, -599, -607, -615, -622, -630, -637, -645, -653, -660, -668, -675, -683, -690, -697, -705, -712, -719, -727, -734, -741, -748, -755, -762, -770, -777, -784, -791, -798, -805, -811, -818, -825, -832, -839, -846, -852, -859, -866, -872, -879, -885, -892, -898, -905, -911, -918, -924, -930, -937, -943, -949, -955, -961, -967, -973, -979, -985, -991, -997, -1003, -1009, -1014, -1020, -1026, -1031, -1037, -1043, -1048, -1054, -1059, -1064, -1070, -1075, -1080, -1086, -1091, -1096, -1101, -1106, -1111, -1116, -1121, -1126, -1131, -1135, -1140, -1145, -1149, -1154, -1159, -1163, -1168, -1172, -1176, -1181, -1185, -1189, -1193, -1198, -1202, -1206, -1210, -1214, -1218, -1221, -1225, -1229, -1233, -1236, -1240, -1244, -1247, -1250, -1254, -1257, -1261, -1264, -1267, -1270, -1273, -1276, -1279, -1282, -1285, -1288, -1291, -1294, -1296, -1299, -1302, -1304, -1307, -1309, -1312, -1314, -1316, -1318, -1321, -1323, -1325, -1327, -1329, -1331, -1333, -1335, -1336, -1338, -1340, -1341, -1343, -1344, -1346, -1347, -1349, -1350, -1351, -1352, -1354, -1355, -1356, -1357, -1357, -1358, -1359, -1360, -1361, -1361, -1362, -1363, -1363, -1363, -1364, -1364, -1364, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1364, -1364, -1364, -1363, -1363, -1363, -1362, -1362, -1361, -1360, -1359, -1359, -1358, -1357, -1356, -1355, -1354, -1353, -1352, -1350, -1349, -1348, -1346, -1345, -1343, -1342, -1340, -1339, -1337, -1335, -1333, -1332, -1330, -1328, -1326, -1324, -1321, -1319, -1317, -1315, -1312, -1310, -1308, -1305, -1302, -1300, -1297, -1295, -1292, -1289, -1286, -1283, -1280, -1277, -1274, -1271, -1268, -1265, -1262, -1258, -1255, -1252, -1248, -1245, -1241, -1238, -1234, -1230, -1226, -1223, -1219, -1215, -1211, -1207, -1203, -1199, -1195, -1191, -1186, -1182, -1178, -1173, -1169, -1165, -1160, -1156, -1151, -1146, -1142, -1137, -1132, -1127, -1122, -1118, -1113, -1108, -1103, -1098, -1092, -1087, -1082, -1077, -1072, -1066, -1061, -1055, -1050, -1044, -1039, -1033, -1028, -1022, -1016, -1011, -1005, -999, -993, -987, -981, -975, -969, -963, -957, -951, -945, -939, -932, -926, -920, -913, -907, -900, -894, -888, -881, -874, -868, -861, -855, -848, -841, -834, -828, -821, -814, -807, -800, -793, -786, -779, -772, -765, -758, -751, -743, -736, -729, -722, -714, -707, -700, -692, -685, -678, -670, -663, -655, -648, -640, -632, -625, -617, -609, -602, -594, -586, -579, -571, -563, -555, -547, -539, -532, -524, -516, -508, -500, -492, -484, -476, -468, -460, -452, -443, -435, -427, -419, -411, -403, -394, -386, -378, -370, -362, -353, -345, -337, -328, -320, -312, -303, -295, -287, -278, -270, -261, -253, -244, -236, -228, -219, -211, -202, -194, -185, -177, -168, -160, -151, -143, -134, -126, -117, -109, -100, -91, -83, -74, -66, -57, -49, -40, -31, -23, -14, -6, 3, 11, 20, 29, 37, 46, 54, 63, 71, 80, 89, 97, 106, 114, 123, 131, 140, 148, 157, 165, 174, 182, 191, 199, 208, 216, 225, 233, 242, 250, 259, 267, 275, 284, 292, 301, 309, 317, 326, 334, 342, 351, 359, 367, 375, 384, 392, 400, 408, 416, 425, 433, 441, 449, 457, 465, 473, 481, 489, 497, 505, 513, 521, 529, 537, 545, 553, 560, 568, 576, 584, 591, 599, 607, 615, 622, 630, 637, 645, 653, 660, 668, 675, 683, 690, 697, 705, 712, 719, 727, 734, 741, 748, 755, 762, 770, 777, 784, 791, 798, 805, 811, 818, 825, 832, 839, 846, 852, 859, 866, 872, 879, 885, 892, 898, 905, 911, 918, 924, 930, 937, 943, 949, 955, 961, 967, 973, 979, 985, 991, 997, 1003, 1009, 1014, 1020, 1026, 1031, 1037, 1043, 1048, 1054, 1059, 1064, 1070, 1075, 1080, 1086, 1091, 1096, 1101, 1106, 1111, 1116, 1121, 1126, 1131, 1135, 1140, 1145, 1149, 1154, 1159, 1163, 1168, 1172, 1176, 1181, 1185, 1189, 1193, 1198, 1202, 1206, 1210, 1214, 1218, 1221, 1225, 1229, 1233, 1236, 1240, 1244, 1247, 1250, 1254, 1257, 1261, 1264, 1267, 1270, 1273, 1276, 1279, 1282, 1285, 1288, 1291, 1294, 1296, 1299, 1302, 1304, 1307, 1309, 1312, 1314, 1316, 1318, 1321, 1323, 1325, 1327, 1329, 1331, 1333, 1335, 1336, 1338, 1340, 1341, 1343, 1344, 1346, 1347, 1349, 1350, 1351, 1352, 1354, 1355, 1356, 1357, 1357, 1358, 1359, 1360, 1361, 1361, 1362, 1363, 1363, 1363, 1364, 1364, 1364, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1364, 1364, 1364, 1363, 1363, 1363, 1362, 1362, 1361, 1360, 1359, 1359, 1358, 1357, 1356, 1355, 1354, 1353, 1352, 1350, 1349, 1348, 1346, 1345, 1343, 1342, 1340, 1339, 1337, 1335, 1333, 1332, 1330, 1328, 1326, 1324, 1321, 1319, 1317, 1315, 1312, 1310, 1308, 1305, 1302, 1300, 1297, 1295, 1292, 1289, 1286, 1283, 1280, 1277, 1274, 1271, 1268, 1265, 1262, 1258, 1255, 1252, 1248, 1245, 1241, 1238, 1234, 1230, 1226, 1223, 1219, 1215, 1211, 1207, 1203, 1199, 1195, 1191, 1186 } int c[]= // C-phase sine wave { -1182, -1186, -1191, -1195, -1199, -1203, -1207, -1211, -1215, -1219, -1223, -1226, -1230, -1234, -1238, -1241, -1245, -1248, -1252, -1255, -1258, -1262, -1265, -1268, -1271, -1274, -1277, -1280, -1283, -1286, -1289, -1292, -1295, -1297, -1300, -1302, -1305, -1308, -1310, -1312, -1315, -1317, -1319, -1321, -1324, -1326, -1328, -1330, -1332, -1333, -1335, -1337, -1339, -1340, -1342, -1343, -1345, -1346, -1348, -1349, -1350, -1352, -1353, -1354, -1355, -1356, -1357, -1358, -1359, -1359, -1360, -1361, -1362, -1362, -1363, -1363, -1363, -1364, -1364, -1364, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1365, -1364, -1364, -1364, -1363, -1363, -1363, -1362, -1361, -1361, -1360, -1359, -1358, -1357, -1357, -1356, -1355, -1354, -1352, -1351, -1350, -1349, -1347, -1346, -1344, -1343, -1341, -1340, -1338, -1336, -1335, -1333, -1331, -1329, -1327, -1325, -1323, -1321, -1318, -1316, -1314, -1312, -1309, -1307, -1304, -1302, -1299, -1296, -1294, -1291, -1288, -1285, -1282, -1279, -1276, -1273, -1270, -1267, -1264, -1261, -1257, -1254, -1250, -1247, -1244, -1240, -1236, -1233, -1229, -1225, -1221, -1218, -1214, -1210, -1206, -1202, -1198, -1193, -1189, -1185, -1181, -1176, -1172, -1168, -1163, -1159, -1154, -1149, -1145, -1140, -1135, -1131, -1126, -1121, -1116, -1111, -1106, -1101, -1096, -1091, -1086, -1080, -1075, -1070, -1064, -1059, -1054, -1048, -1043, -1037, -1031, -1026, -1020, -1014, -1009, -1003, -997, -991, -985, -979, -973, -967, -961, -955, -949, -943, -937, -930, -924, -918, -911, -905, -898, -892, -885, -879, -872, -866, -859, -852, -846, -839, -832, -825, -818, -811, -805, -798, -791, -784, -777, -770, -762, -755, -748, -741, -734, -727, -719, -712, -705, -697, -690, -683, -675, -668, -660, -653, -645, -637, -630, -622, -615, -607, -599, -591, -584, -576, -568, -560, -553, -545, -537, -529, -521, -513, -505, -497, -489, -481, -473, -465, -457, -449, -441, -433, -425, -416, -408, -400, -392, -384, -375, -367, -359, -351, -342, -334, -326, -317, -309, -301, -292, -284, -275, -267, -259, -250, -242, -233, -225, -216, -208, -199, -191, -182, -174, -165, -157, -148, -140, -131, -123, -114, -106, -97, -89, -80, -71, -63, -54, -46, -37, -29, -20, -11, -3, 6, 14, 23, 31, 40, 49, 57, 66, 74, 83, 91, 100, 109, 117, 126, 134, 143, 151, 160, 168, 177, 185, 194, 202, 211, 219, 228, 236, 244, 253, 261, 270, 278, 287, 295, 303, 312, 320, 328, 337, 345, 353, 362, 370, 378, 386, 394, 403, 411, 419, 427, 435, 443, 452, 460, 468, 476, 484, 492, 500, 508, 516, 524, 532, 539, 547, 555, 563, 571, 579, 586, 594, 602, 609, 617, 625, 632, 640, 648, 655, 663, 670, 678, 685, 692, 700, 707, 714, 722, 729, 736, 743, 751, 758, 765, 772, 779, 786, 793, 800, 807, 814, 821, 828, 834, 841, 848, 855, 861, 868, 874, 881, 888, 894, 900, 907, 913, 920, 926, 932, 939, 945, 951, 957, 963, 969, 975, 981, 987, 993, 999, 1005, 1011, 1016, 1022, 1028, 1033, 1039, 1044, 1050, 1055, 1061, 1066, 1072, 1077, 1082, 1087, 1092, 1098, 1103, 1108, 1113, 1118, 1122, 1127, 1132, 1137, 1142, 1146, 1151, 1156, 1160, 1165, 1169, 1173, 1178, 1182, 1186, 1191, 1195, 1199, 1203, 1207, 1211, 1215, 1219, 1223, 1226, 1230, 1234, 1238, 1241, 1245, 1248, 1252, 1255, 1258, 1262, 1265, 1268, 1271, 1274, 1277, 1280, 1283, 1286, 1289, 1292, 1295, 1297, 1300, 1302, 1305, 1308, 1310, 1312, 1315, 1317, 1319, 1321, 1324, 1326, 1328, 1330, 1332, 1333, 1335, 1337, 1339, 1340, 1342, 1343, 1345, 1346, 1348, 1349, 1350, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1359, 1360, 1361, 1362, 1362, 1363, 1363, 1363, 1364, 1364, 1364, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1364, 1364, 1364, 1363, 1363, 1363, 1362, 1361, 1361, 1360, 1359, 1358, 1357, 1357, 1356, 1355, 1354, 1352, 1351, 1350, 1349, 1347, 1346, 1344, 1343, 1341, 1340, 1338, 1336, 1335, 1333, 1331, 1329, 1327, 1325, 1323, 1321, 1318, 1316, 1314, 1312, 1309, 1307, 1304, 1302, 1299, 1296, 1294, 1291, 1288, 1285, 1282, 1279, 1276, 1273, 1270, 1267, 1264, 1261, 1257, 1254, 1250, 1247, 1244, 1240, 1236, 1233, 1229, 1225, 1221, 1218, 1214, 1210, 1206, 1202, 1198, 1193, 1189, 1185, 1181, 1176, 1172, 1168, 1163, 1159, 1154, 1149, 1145, 1140, 1135, 1131, 1126, 1121, 1116, 1111, 1106, 1101, 1096, 1091, 1086, 1080, 1075, 1070, 1064, 1059, 1054, 1048, 1043, 1037, 1031, 1026, 1020, 1014, 1009, 1003, 997, 991, 985, 979, 973, 967, 961, 955, 949, 943, 937, 930, 924, 918, 911, 905, 898, 892, 885, 879, 872, 866, 859, 852, 846, 839, 832, 825, 818, 811, 805, 798, 791, 784, 777, 770, 762, 755, 748, 741, 734, 727, 719, 712, 705, 697, 690, 683, 675, 668, 660, 653, 645, 637, 630, 622, 615, 607, 599, 591, 584, 576, 568, 560, 553, 545, 537, 529, 521, 513, 505, 497, 489, 481, 473, 465, 457, 449, 441, 433, 425, 416, 408, 400, 392, 384, 375, 367, 359, 351, 342, 334, 326, 317, 309, 301, 292, 284, 275, 267, 259, 250, 242, 233, 225, 216, 208, 199, 191, 182, 174, 165, 157, 148, 140, 131, 123, 114, 106, 97, 89, 80, 71, 63, 54, 46, 37, 29, 20, 11, 3, -6, -14, -23, -31, -40, -49, -57, -66, -74, -83, -91, -100, -109, -117, -126, -134, -143, -151, -160, -168, -177, -185, -194, -202, -211, -219, -228, -236, -244, -253, -261, -270, -278, -287, -295, -303, -312, -320, -328, -337, -345, -353, -362, -370, -378, -386, -394, -403, -411, -419, -427, -435, -443, -452, -460, -468, -476, -484, -492, -500, -508, -516, -524, -532, -539, -547, -555, -563, -571, -579, -586, -594, -602, -609, -617, -625, -632, -640, -648, -655, -663, -670, -678, -685, -692, -700, -707, -714, -722, -729, -736, -743, -751, -758, -765, -772, -779, -786, -793, -800, -807, -814, -821, -828, -834, -841, -848, -855, -861, -868, -874, -881, -888, -894, -900, -907, -913, -920, -926, -932, -939, -945, -951, -957, -963, -969, -975, -981, -987, -993, -999, -1005, -1011, -1016, -1022, -1028, -1033, -1039, -1044, -1050, -1055, -1061, -1066, -1072, -1077, -1082, -1087, -1092, -1098, -1103, -1108, -1113, -1118, -1122, -1127, -1132, -1137, -1142, -1146, -1151, -1156, -1160, -1165 -1169, -1173, -1178 } // Enable Period interrupt and Under flow interrupt bits for GP timer 1 and timer 3 EvaRegs.EVAIMRA.bit.T1UFINT=1; EvaRegs.EVAIFRA.bit.T1UFINT=1; EvaRegs.EVAIMRA.bit.T3UFINT=1; EvaRegs.EVAIFRA.bit.T3UFINT=1; // EVA Configure PWM1-PWM6 // Initalize EVA Timer1 EvaRegs.T1CNT = 0x0000; // Timer1 counter EvaRegs.T1PR = 0x124F; // Timer1 period // TMODE = continuous up/down // Timer enable // X/8 EvaRegs.T1CON.all = 0x0BC1; // Initalize EVA Timer2 EvaRegs.T2CNT = 0x0000; // Timer2 counter // TMODE = continuous up/down // Timer enable // X/8 EvaRegs.T2CON.all = 0x0BC1; // Initalize EVA Timer3 EvaRegs.T3CNT = 0x0000; // Timer3 counter EvaRegs.T3PR = 0x124F; // Timer3 period // TMODE = continuous up/down // Timer enable // Timer compare enable EvaRegs.T3CON.all = 0x0BC1; // Initalize EVA Timer4 EvaRegs.T4CNT = 0x0000; // Timer2 counter // TMODE = continuous up/down // Timer enable // X/8 EvaRegs.T4CON.all = 0x0BC1; // Compare action control. Action that takes place // on a cmpare event // output pin 1 CMPR1 - active high // output pin 2 CMPR1 - active low // output pin 3 CMPR2 - active high // output pin 4 CMPR2 - active low // output pin 5 CMPR3 - active high // output pin 6 CMPR3 - active low EvaRegs.ACTRA.all = 0x0666; EvaRegs.DBTCONA.all = 0x0000; // Disable deadband EvaRegs.COMCONA.all = 0x82E0; EvaRegs.EXTCONA.all = 0x0009; // Compare action control. Action that takes place // on a cmpare event // output pin 7 CMPR4 - active high // output pin 8 CMPR4 - active low // output pin 9 CMPR5 - active high // output pin 10 CMPR5 - active low // output pin 11 CMPR6 - active high // output pin 12 CMPR6 - active low EvaRegs.ACTRB.all = 0x0666; EvaRegs.DBTCONB.all = 0x0000; // Disable deadband EvaRegs.COMCONB.all = 0x82E0; EvaRegs.EXTCONB.all = 0x0009; j=j+40*ma; i=j; ka=a[i]; kb=b[i]; kc=c[i]; // Enable compare for PWM1-PWM6 EvaRegs.CMPR1 = ka; EvaRegs.CMPR2 = kb; EvaRegs.CMPR3 = kc; // Enable compare for PWM7-PWM12 EvaRegs.CMPR4 = ka; EvaRegs.CMPR5 = kb; EvaRegs.CMPR6 = kc; }
Hi Kiran,
First suggestion is try the sine wave generation library provided in control suite. See if it meets your requirement. It simplifies the wave generation process.
Vivek
From your code i can see that you need to generate a sine wave of 50Hz (=fs) and for that the carrier frequency is 2KHz( = fc). If my assumptions are correct then you need to have only (2000/50) values only in your sine table. Which = 40. Your sine table has more values than that.
Vivek
Thank you sir, i have 1000 samples of sine wave and i will take first sample after that 26th sample for 50HZ. for 40HZ after 1st sample 21st will be taken. this is for V/F control. number of samples are not the matter but the interrupts or some declaration error may be there which i am facing difficult to find out. help me please....
So one more thing i noticed is you are copying ka, kb, kc values to CMPA. Won't ka, kb and kc be negative for sine values from 180degs to 360 degs. And that cannot be directly copied to CMPR because CMPR takes only positive values.
Vivek
(P.S: Call me Vivek please.)
Control Suite is a complete software package for C2000 Family. Though it is mostly for use with higher end C2000, some codes can reused for F2812.
http://www.ti.com/tool/controlsuite
Vivek
Can you explain the math to me a little bit. How did you generate the sine table? Does it contain CMPR values staightaway?
Vivek
Sir, i have taken 1000 samples for one cycle in MATLAB. and i have converted all these instantaneous values to digital values by using the formula (4095* instantaneous value)/3 . these i have taken in a array format. somebody suggested me this, but actually i donot know whether it is correct or not.
Vivek -
I'm not sure how compatible the code in the Signal Generation section of the Control Suite will be with the F28x series processors - I'm implementing one in my code and it appears that there's a lookup table in the Delfino series that the modules rely on (if I read it correctly) and all the examples are written for the Delfino series. One would have to check if the F28x has the same table. they are .asm modules that are C-callable, so if the chip will support it, he can use them.
Tony
Kiran,
If this helps as well, I have attached a pdf from the control suite that describes the C-callable .asm modules, as well as a sample C program that utilizes one of the modules. I suggest, as Vivek did, that you download ControlSuite from TI and view the modules. Review the datasheet on your processor to see if there's compatibility. This Control Suite is a wealth of information and example code, especially in the Signal Generation section.
Tony
Tony
It apears that the files did not attach properly. Here they are again:
// ===================================================================================== // This software is licensed for use with Texas Instruments C28x // family DSCs. This license was provided to you prior to installing // the software. You may review this license by consulting a copy of // the agreement in the doc directory of this library. // ------------------------------------------------------------------------------------- // Copyright (C) 2010-2011 Texas Instruments, Incorporated. // All Rights Reserved. //====================================================================================== /* ============================================================================== System Name: Signal Generator Module demo File Name: SGENT1.C Description: Primary System file for demonstrating the Signal Generator module Originator: Digital control systems Group - Texas Instruments Target dependency: C28x Description: ============ The "C" frame work, for demonstrating the signal generator module is given below ___________ _____________ | | | | | | X1=OUT | EVMDAC | | SGENT_1 |-------->| DLOG_4CH | | | | PWMDAC | |___________| |_____________| */ //###################################################################################### // $TI Release: C28x SGEN Library Version v1.01 $ // $Release Date: September 30, 2011 $ //###################################################################################### #include "DSP28x_Project.h" // Device Headerfile and Examples Include File #include <sgen.h> #define SIGNAL_LENGTH 512 /* Create an instance of Signal generator module */ SGENT_1 sgen = SGENT_1_DEFAULTS; #pragma DATA_SECTION(ipcb, "SGENipcb"); int ipcb[SIGNAL_LENGTH]; int xn,yn; void main() { unsigned long i; InitSysCtrl(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM /* Signal Generator module initialisation */ sgen.offset=0; sgen.gain=0x7fff; /* gain=1 in Q15 */ sgen.freq=5369; /* freq = (Required Freq/Max Freq)*2^15 */ /* = (50/305.17)*2^15 = 5369 */ sgen.step_max=1000; /* Max Freq= (step_max * sampling freq)/65536 */ sgen.alpha=8192; /* phase_norm =(pi/4/(2*pi))*2^16=8192 */ /* So call step_max is normalized fmax in Q16 format */ /* step_max=fmax/fs*65536 */ /* f/fmax*2^15=freq */ for(i=0;i<SIGNAL_LENGTH;i++) { ipcb[i]=0; } for(i=0;i<SIGNAL_LENGTH;i++) { sgen.calc(&sgen); xn=sgen.out; ipcb[i]=xn; } for(;;); } /* End: main() */
Kiran-
So take a look at the pdfs anthony has attached. see if your processor supports the .asm routine (You can possibly open a new thread on the forum to post that query). If it doesn't work out, post back on this thread. We can generate the sine wave without the software package pretty easily too.
Vivek
Thank you sir for your kind reply,
may i know what is the significance of sgen.step_max(take 1000), sgen.phase(taken 4000h).
Thank You sir,
i am taking array of sin values(values generated from MATLAB directly). will it work
Yes.. But 1000 values are too much. Take a table of 256 values. These values can straightaway have the CMPR values in them. This can be done in an excel sheet. Note that sin 0 corresponds to 50% duty cycle, sin 90 corresponds to 100%, Sin 270 will be 0% duty and sin 360 is again 50%.
Example calculation
Epwm Time period = 1000; // This value is just an example. But it must be equal to the time period used for carrier frequency.
Array index Angle(deg) Sin(Angle) Value Stored = CMPR Value = ((sin(Angle) + 1.65)/3.3) * (Epwm Time Period)
sineTable[0] 0 0 500
:
:
:
sinTable[63] 90 1 1000
:
:
:
SineTable[127] 270 -1 0
:
:
:
SineTable[255] 360 0 500
In every interrupt you will go and copy the last column in the CMPR. Hope this helps... Post in case of doubts.
Vivek
Thank You sir, for your kind reply.
sir here, Value Stored = CMPR Value = ((sin(Angle) + 1.65)/3.3) * (Epwm Time Period), why are we adding 1.65 and dividing with 3.3.
3.3V corresponds to 100% duty cycle on the pin. 1.65V corresponds to 50% duty cycle on the pin. You want sin0 to correspond to 1.65V and sin90 to correspond to 3.3V.
So you finally get a sine wave that is centred on 1.65 volts that has a top peak at 2.65 volts and a bottom peak of 0.65V.
Vivek
sir, when i am taking sine wave data in an array, it is giving Error: expected an expression. what may be the reason. please....
Kiran,
Don't be afraid to call us by our names, you don't have to call us "sir" :-) Can you attach your troublesome code, or just the line that you are having a problem with?
Tony
Thank You very much,
in a sine-triangle modulation for five-level inverter where one sine wave (amplitude from -1 to 1) and four triangler waves( each having amplitude 0.5, i.e. from -1 to -0.5, -0.5 to 0, 0 to 0.5, 0.5 to 1). But in implementation with DSP we have one trianglar wave from 0 to 0.5. so some offset value is added to the sine wave to adjust it between 0 to 0.5 as shown in the figure attached to this mail. But i need the pulse when sine wave (from -1 to -0.5) is compared with triangler wave, when sine wave (from -0.5 to 0) is compared with triangler wave, when sine wave (from 0 to 0.5) is compared with triangler wave, when sine wave (from 0.5 to 1) is compared with triangler wave indipendently. like wise for B-phase and C-phase. any help to achieve this. here i am attaching my code also please see this.
here i am attaching my code.
//########################################################################### // $TI Release: DSP281x C/C++ Header Files V1.20 $ // $Release Date: July 27, 2009 $ //########################################################################### #include "DSP281x_Device.h" // DSP281x Headerfile Include File #include "DSP281x_Examples.h" // DSP281x Examples Include File interrupt void eva_timer1_isr(void); void main(void) { //Step 1. Initialize System Control registers, PLL, WatchDog, // peripheral Clocks to default state: // This function is found in the DSP281x_SysCtrl.c file. InitSysCtrl(); // Initialize only GPAMUX and GPBMUX for this test EALLOW; // Enable PWM pins GpioMuxRegs.GPAMUX.all = 0x00FF; // EVA PWM 1-6 pins EDIS; // Step 2. Initalize GPIO: // This example function is found in the DSP281x_Gpio.c file and // illustrates how to set the GPIO to it's default state. //InitGpio(); // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the DSP281x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP281x_DefaultIsr.c. // This function is found in DSP281x_PieVect.c. InitPieVectTable(); //InitPeripherals(); // enable interrupts // EvaRegs.EVAIMRA.bit.T1PINT = 1; // EvaRegs.EVAIFRA.bit.T1PINT = 1; EvaRegs.EVAIMRA.bit.T1UFINT = 1; EvaRegs.EVAIFRA.bit.T1UFINT = 1; // Initalize EVA Timer1 EvaRegs.T1PR = 0x1171; // Timer1 period EvaRegs.T1CNT = 0x0000; // Timer1 counter // TMODE = continuous up/down // Timer enable // Timer compare enable // input clock prescaler 001=x/2 EvaRegs.T1CON.all = 0x0EC3; // Compare action control. Action that takes place // on a cmpare event // output pin 1 CMPR1 - active high // output pin 2 CMPR1 - active low // output pin 3 CMPR2 - active high // output pin 4 CMPR2 - active low // output pin 5 CMPR3 - active high // output pin 6 CMPR3 - active low EvaRegs.ACTRA.all = 0x0666; EvaRegs.DBTCONA.all = 0x0000; // Disable deadband EvaRegs.COMCONA.all = 0x82E0; // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.T1UFINT = &eva_timer1_isr; //PieVectTable.T1PINT = &eva_timer1_isr; EDIS; // This is needed to disable write to EALLOW protected registers // Enable PIE group 2 interrupt 4 for T1PINT // PieCtrlRegs.PIEIER2.all = M_INT4; //M_INT4=0x0008 // Enable PIE group 2 interrupt 6 for T1UFINT PieCtrlRegs.PIEIER2.all = M_INT6; //M_INT4=0x0020 // Enable CPU INT2 for T1PINT and T1UFINT IER = (M_INT2); EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM for(;;); } interrupt void eva_timer1_isr(void) { float ma=1.0; static float j=0.0; int ia,ib,ic; int a[1000] = {0,15,30,44,59,74,88,103,118,132,147,162,176,191,206,220,235,250,265,279,294,308,323,337,352,366,381,395,410,425,439,453,468,482,497,511,526,540,554,568,583,597,611,625,640,654,668,682,696,710,724,738,752,766,780,794,807,821,835,849,862,876,890,903,917,930,944,957,971,984,998,1011,1024,1037,1051,1064,1077,1090,1103,1116,1129,1142,1154,1167,1180,1193,1205,1218,1231,1243,1255,1268,1280,1292,1305,1317,1329,1341,1353,1365,1377,1389,1401,1413,1424,1436,1448,1459,1471,1482,1493,1505,1516,1527,1538,1549,1560,1571,1582,1593,1604,1615,1625,1636,1646,1657,1667,1677,1688,1698,1708,1718,1728,1738,1748,1757,1767,1777,1786,1796,1805,1815,1824,1833,1842,1851,1860,1869,1878,1887,1895,1904,1913,1921,1929,1938,1946,1954,1962,1970,1978,1986,1994,2002,2009,2017,2024,2032,2039,2046,2053,2060,2067,2074,2081,2088,2094,2101,2107,2114,2120,2126,2132,2138,2144,2150,2156,2162,2168,2173,2179,2184,2189,2194,2199,2205,2209,2214,2219,2224,2228,2233,2237,2242,2246,2250,2254,2258,2262,2266,2269,2273,2276,2280,2283,2287,2290,2293,2296,2299,2302,2304,2307,2309,2312,2314,2317,2319,2321,2323,2324,2326,2328,2330,2331,2333,2334,2335,2336,2337,2338,2339,2340,2341,2341,2342,2342,2343,2343,2343,2343,2343,2343,2343,2342,2342,2341,2341,2340,2339,2338,2337,2336,2335,2334,2333,2331,2330,2328,2326,2324,2323,2321,2319,2317,2314,2312,2309,2307,2304,2302,2299,2296,2293,2290,2287,2283,2280,2276,2273,2269,2266,2262,2258,2254,2250,2246,2242,2237,2233,2228,2224,2219,2214,2209,2205,2199,2194,2189,2184,2179,2173,2168,2162,2156,2150,2144,2138,2132,2126,2120,2114,2107,2101,2094,2088,2081,2074,2067,2060,2053,2046,2039,2032,2024,2017,2009,2002,1994,1986,1978,1970,1962,1954,1946,1938,1929,1921,1913,1904,1895,1887,1878,1869,1860,1851,1842,1833,1824,1815,1805,1796,1786,1777,1767,1757,1748,1738,1728,1718,1708,1698,1688,1677,1667,1657,1646,1636,1625,1615,1604,1593,1582,1571,1560,1549,1538,1527,1516,1505,1493,1482,1471,1459,1448,1436,1424,1413,1401,1389,1377,1365,1353,1341,1329,1317,1305,1292,1280,1268,1255,1243,1231,1218,1205,1193,1180,1167,1154,1142,1129,1116,1103,1090,1077,1064,1051,1037,1024,1011,998,984,971,957,944,930,917,903,890,876,862,849,835,821,807,794,780,766,752,738,724,710,696,682,668,654,640,625,611,597,583,568,554,540,526,511,497,482,468,453,439,425,410,395,381,366,352,337,323,308,294,279,265,250,235,220,206,191,176,162,147,132,118,103,88,74,59,44,30,15,0,-15,-30,-44,-59,-74,-88,-103,-118,-132,-147,-162,-176,-191,-206,-220,-235,-250,-265,-279,-294,-308,-323,-337,-352,-366,-381,-395,-410,-425,-439,-453,-468,-482,-497,-511,-526,-540,-554,-568,-583,-597,-611,-625,-640,-654,-668,-682,-696,-710,-724,-738,-752,-766,-780,-794,-807,-821,-835,-849,-862,-876,-890,-903,-917,-930,-944,-957,-971,-984,-998,-1011,-1024,-1037,-1051,-1064,-1077,-1090,-1103,-1116,-1129,-1142,-1154,-1167,-1180,-1193,-1205,-1218,-1231,-1243,-1255,-1268,-1280,-1292,-1305,-1317,-1329,-1341,-1353,-1365,-1377,-1389,-1401,-1413,-1424,-1436,-1448,-1459,-1471,-1482,-1493,-1505,-1516,-1527,-1538,-1549,-1560,-1571,-1582,-1593,-1604,-1615,-1625,-1636,-1646,-1657,-1667,-1677,-1688,-1698,-1708,-1718,-1728,-1738,-1748,-1757,-1767,-1777,-1786,-1796,-1805,-1815,-1824,-1833,-1842,-1851,-1860,-1869,-1878,-1887,-1895,-1904,-1913,-1921,-1929,-1938,-1946,-1954,-1962,-1970,-1978,-1986,-1994,-2002,-2009,-2017,-2024,-2032,-2039,-2046,-2053,-2060,-2067,-2074,-2081,-2088,-2094,-2101,-2107,-2114,-2120,-2126,-2132,-2138,-2144,-2150,-2156,-2162,-2168,-2173,-2179,-2184,-2189,-2194,-2199,-2205,-2209,-2214,-2219,-2224,-2228,-2233,-2237,-2242,-2246,-2250,-2254,-2258,-2262,-2266,-2269,-2273,-2276,-2280,-2283,-2287,-2290,-2293,-2296,-2299,-2302,-2304,-2307,-2309,-2312,-2314,-2317,-2319,-2321,-2323,-2324,-2326,-2328,-2330,-2331,-2333,-2334,-2335,-2336,-2337,-2338,-2339,-2340,-2341,-2341,-2342,-2342,-2343,-2343,-2343,-2343,-2343,-2343,-2343,-2342,-2342,-2341,-2341,-2340,-2339,-2338,-2337,-2336,-2335,-2334,-2333,-2331,-2330,-2328,-2326,-2324,-2323,-2321,-2319,-2317,-2314,-2312,-2309,-2307,-2304,-2302,-2299,-2296,-2293,-2290,-2287,-2283,-2280,-2276,-2273,-2269,-2266,-2262,-2258,-2254,-2250,-2246,-2242,-2237,-2233,-2228,-2224,-2219,-2214,-2209,-2205,-2199,-2194,-2189,-2184,-2179,-2173,-2168,-2162,-2156,-2150,-2144,-2138,-2132,-2126,-2120,-2114,-2107,-2101,-2094,-2088,-2081,-2074,-2067,-2060,-2053,-2046,-2039,-2032,-2024,-2017,-2009,-2002,-1994,-1986,-1978,-1970,-1962,-1954,-1946,-1938,-1929,-1921,-1913,-1904,-1895,-1887,-1878,-1869,-1860,-1851,-1842,-1833,-1824,-1815,-1805,-1796,-1786,-1777,-1767,-1757,-1748,-1738,-1728,-1718,-1708,-1698,-1688,-1677,-1667,-1657,-1646,-1636,-1625,-1615,-1604,-1593,-1582,-1571,-1560,-1549,-1538,-1527,-1516,-1505,-1493,-1482,-1471,-1459,-1448,-1436,-1424,-1413,-1401,-1389,-1377,-1365,-1353,-1341,-1329,-1317,-1305,-1292,-1280,-1268,-1255,-1243,-1231,-1218,-1205,-1193,-1180,-1167,-1154,-1142,-1129,-1116,-1103,-1090,-1077,-1064,-1051,-1037,-1024,-1011,-998,-984,-971,-957,-944,-930,-917,-903,890,-876,-862,-849,-835,-821,-807,-794,-780,-766,-752,-738,-724,-710,-696,-682,-668,-654,-640,-625,-611,-597,-583,-568,-554,-540,-526,-511,-497,-482,-468,-453,-439,-425,-410,-395,-381,-366,-352,-337,-323,-308,-294,-279,-265,-250,-235,-220,-206,-191,-176,-162,-147,-132,-118,-103,-88,-74,-59,-44,-30,-15}; // Enable more interrupts from this timer //EvaRegs.EVAIMRA.bit.T1PINT = 1; EvaRegs.EVAIMRA.bit.T1UFINT = 1; EvaRegs.EVAIFRA.bit.T1UFINT = 1; // Acknowledge interrupt to receive more interrupts from PIE group 2 PieCtrlRegs.PIEACK.all = PIEACK_GROUP2; if(j>1000) { j=0; } ia=j; ib=j+334; ic=j+668; if(ia>1000) { ia=ia-1000; } if(ib>1000) { ib=ib-1000; } if(ic>1000) { ic=ic-1000; } //adding offset2 to bring all the sine wave with in one triangler wave // A-phase if (1171<a[ia]<2343) { a[ia]=a[ia]-1171; } else if (0<a[ia]<1171) { a[ia]=a[ia]; } else if (-1171<a[ia]<0) { a[ia]=a[ia]+1171; } else (-2343<a[ia]<-1171) { a[ia]=a[ia]+2343; } //B-phase if (1171<a[ib]<2343) { a[ib]=a[ib]-1171; } else if (0<a[ib]<1171) { a[ib]=a[ib]; } else if (-1171<a[ib]<0) { a[ib]=a[ib]+1171; } else (-2343<a[ib]<-1171) { a[ib]=a[ib]+2343; } // C-phase if (1171<a[ic]<2343) { a[ic]=a[ic]-1171; } else if (0<a[ic]<1171) { a[ic]=a[ic]; } else if (-1171<a[ic]<0) { a[ic]=a[ic]+1171; } else (-2343<a[ic]<-1171) { a[ic]=a[ic]+2343; } //EvaRegs.T1CON.all = 0x0DC3; // Enable compare for PWM1-PWM6 EvaRegs.CMPR1 = a[ia]; EvaRegs.CMPR2 = a[ib]; EvaRegs.CMPR3 = a[ic]; j=j+25*ma; } //=========================================================================== // No more. //===========================================================================
Which line is giving you an error for the sine data? You did not specify so I wil make a general assumption. From what I can see you have several similar expressions:
if (1171 < a[ic] <2343)
I am assuming that the compiler doesn't like your comparison within the "if()" statement. I have run into this issue once or twice myself. Try using this instead:
if (a[ic] >1171 && a[ic] < 2343)
See if that helps. And let me know where you were having the error.
Tony
Thank you very much sir. yes now it is working fine after changing if statement as You have suggested. thank You.
Thank You very much,
in a sine-triangle modulation for five-level inverter where one sine wave (amplitude from -2343 to 2343) and four triangular waves( each having amplitude 1171). But in implementation with DSP we have one triangular wave from 0 to 1171. so some offset value is added to the sine wave to adjust it between 0 to 1171 as shown in the figure attached to this mail. But i need the pulse when sine wave (from -2343 to -1171) is compared with triangular wave, when sine wave (from -1171 to 0) is compared with triangular wave, when sine wave (from 0 to 01171) is compared with triangular wave, when sine wave (from 1171 to 2343) is compared with triangular wave independently. any help to achieve this.