Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help identify C compiler for a car stereo remote control (PIC)

Status
Not open for further replies.

nilses

Member level 2
Joined
Aug 22, 2013
Messages
45
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,715
Hi,

One of my friends found an example remote control for a car stereo written in C. I have tried to compile this sourcecode without success. I need help to identify the compiler.

Source is below:

Best regards,

Nils


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
//please excuse the lack of comments
// this works with a simgle button and has the correct timings
 
// adding the send of signals to stereo.. simulating by sending to serial
#include <system.h>
#define CHECK_MS 5
#define DOUBLE_MS 400
#define HOLD_MS 1200
 
#define NO_B 839 //nothing pressed
#define MODE_B 662 // MODE
#define NXTU_B 509 // NEXT UP
#define NXTD_B 380 // NEXT DOWN
#define MUTE_B 273 // MUTE
#define VOLU_B 180 // VOLUME UP
#define VOLD_B 105 // VOLUME DOWN
 
#define alpPin 7
 
boolean volUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,1,0,1,1,0,1,1, 1,1,0,1,0,1,1,0, 1,1,0,1,0,1,0,1};
boolean volDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,0,1,1,0,1, 1,1,1,1,0,1,1,0, 1,1,0,1,0,1,0,1};
boolean mute[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,0,1,1,0,1, 1,1,1,0,1,1,1,0, 1,1,0,1,0,1,0,1};
boolean pstUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,0,1,0,1,1, 1,1,1,0,1,1,1,1, 0,1,0,1,0,1,0,1};
boolean pstDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,0,1,0,1, 1,1,1,1,1,1,1,1, 0,1,0,1,0,1,0,1};
boolean source[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,1,0,1,1,1, 1,1,0,1,1,0,1,1, 0,1,0,1,0,1,0,1};
boolean trkUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,1,1,0,1,1, 1,1,0,1,1,0,1,0, 1,1,0,1,0,1,0,1};
boolean trkDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,1,1,0,1, 1,1,1,1,1,0,1,0, 1,1,0,1,0,1,0,1};
boolean power[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,1,0,1,1,1, 1,1,1,0,1,0,1,1, 0,1,0,1,0,1,0,1};
boolean entPlay[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,0,1,1,1, 1,1,1,1,1,1,0,1, 0,1,0,1,0,1,0,1};
boolean bandProg[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,0,1,0,1,1, 1,1,1,1,0,1,1,1, 0,1,0,1,0,1,0,1};
 
boolean spFlag = 0;
boolean dpFlag = 0;
boolean hpFlag = 0;
 
int button = 0; 
int spbutton = 0;
/*
0-none
1-mode
2-track +
3-track -
4-mute
5-vol+
6-vol-
*/
 
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT);
 
}
 
void loop() {
static unsigned long oldTime = 0;
int switchStatus = 0;
if (millis() >= oldTime + CHECK_MS) {
oldTime = millis();
switchStatus = CheckSwitch();
 
if (switchStatus == 0) {
//no button press
 
} else if (switchStatus == 1) {
// single press
switch (spbutton) {
case 0: // no butto, why are wh here
break;
case 1: // mode
modeSend();
break;
case 2: // next up
trkUpSend();
break;
case 3: // next down
trkDnSend();
break;
case 4: // mute
muteSend();
break;
case 5: // vol up
volUpSend();
break;
case 6: // vol down
volDnSend();
break;
} 
} else if (switchStatus == 2) {
//double press
switch (spbutton) {
case 0: // no butto, why are wh here
break;
case 1: // mode
sourceSend();
break;
case 2: // next up
trkUpSend();
break;
case 3: // next down
trkDnSend();
break;
case 4: // mute
muteSend();
break;
case 5: // vol up
volUpSend();
break;
case 6: // vol down
volDnSend();
break;
} 
} else if (switchStatus == 3) {
//hold
switch (spbutton) {
case 0: // no butto, why are wh here
break;
case 1: // mode
modeSend();
break;
case 2: // next up
trkUpSend();
break;
case 3: // next down
trkDnSend();
break;
case 4: // mute
muteSend();
break;
case 5: // vol up
volUpSend();
break;
case 6: // vol down
volDnSend();
break;
} 
} 
 
}
}
 
// Service routine called by a timer interrupt
int CheckSwitch() {
static uint16_t State = 0; // Current debounce status
static int curTime = 0;
 
State=(State<<1) | !RawKeyPressed() | 0xe000;
if (!spFlag) {
if (hpFlag) {
if (State == 0xe000) {
return 3;
} else {
hpFlag = 0;
}
}
if (State==0xf000) {
spFlag = 1;
hpFlag = 1;
dpFlag = 1;
curTime = 0;
spbutton = button;
return 0;
}
} 
if (hpFlag && State != 0xe000) {
hpFlag = 0;
}
if (spFlag && hpFlag && curTime > HOLD_MS/CHECK_MS) {
spFlag = 0;
dpFlag = 0;
return 3;
} else if (spFlag && dpFlag && State == 0xf000 && curTime < DOUBLE_MS) {
spFlag = 0;
hpFlag = 0;
dpFlag = 0;
return 2;
} else if (spFlag && !hpFlag && curTime > DOUBLE_MS) {
spFlag = 0;
hpFlag = 0;
dpFlag = 0;
return 1;
} else {
curTime = curTime + CHECK_MS;
return 0;
}
}
 
boolean RawKeyPressed() {
int anaPin = 0;
anaPin = analogRead(0);
if (anaPin > NO_B - 20) {
button = 0;
return 0;
} else if (anaPin > MODE_B - 20 && anaPin < MODE_B + 20 ) {
button = 1;
return 1;
} else if (anaPin > NXTU_B - 20 && anaPin < NXTU_B + 20 ) {
button = 2;
return 1;
} else if (anaPin > NXTD_B - 20 && anaPin < NXTD_B + 20 ) {
button = 3;
return 1;
} else if (anaPin > MUTE_B - 20 && anaPin < MUTE_B + 20 ) {
button = 4;
return 1;
} else if (anaPin > VOLU_B - 20 && anaPin < VOLU_B + 20 ) {
button = 5;
return 1;
} else if (anaPin < VOLD_B + 20 ) {
button = 6;
return 1;
} else {
button = 0;
return 0;
}
}
 
//-----------SOURCE------------------
void sourceSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (source[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}
 
 
//---------MODE-----------------------------------------------
void modeSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (entPlay[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}
 
 
//---------NEXT UP-----------------------------------------------
void trkUpSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (trkUp[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}
 
//---------NEXT DOWN----------------------------------------------
void trkDnSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (trkDn[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}
 
 
//---------MUTE---------------------------------------------------
void muteSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (mute[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}
 
//---------VOL UP-----------------------------------------------
void volUpSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (volUp[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}
 
 
//---------VOL DOWN-----------------------------------------------
void volDnSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
 
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (volDn[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
} 
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41); 
}

[Settings]
Active Directory=C:\
 
Last edited by a moderator:

Hello,

I think this was designed for a low pin PIC but I'm not sure.

The difficult part is below:

How to translate to a common compiler ?

Best regards,

Nils



boolean volUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,1,0,1,1,0,1,1, 1,1,0,1,0,1,1,0, 1,1,0,1,0,1,0,1};
boolean volDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,0,1,1,0,1, 1,1,1,1,0,1,1,0, 1,1,0,1,0,1,0,1};
boolean mute[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,0,1,1,0,1, 1,1,1,0,1,1,1,0, 1,1,0,1,0,1,0,1};
boolean pstUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,0,1,0,1,1, 1,1,1,0,1,1,1,1, 0,1,0,1,0,1,0,1};
boolean pstDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,0,1,0,1, 1,1,1,1,1,1,1,1, 0,1,0,1,0,1,0,1};
boolean source[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,1,0,1,1,1, 1,1,0,1,1,0,1,1, 0,1,0,1,0,1,0,1};
boolean trkUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,1,1,0,1,1, 1,1,0,1,1,0,1,0, 1,1,0,1,0,1,0,1};
boolean trkDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,1,1,0,1, 1,1,1,1,1,0,1,0, 1,1,0,1,0,1,0,1};
boolean power[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,1,0,1,1,1, 1,1,1,0,1,0,1,1, 0,1,0,1,0,1,0,1};
boolean entPlay[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,0,1,1,1, 1,1,1,1,1,1,0,1, 0,1,0,1,0,1,0,1};
boolean bandProg[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,0,1,0,1,1, 1,1,1,1,0,1,1,1, 0,1,0,1,0,1,0,1};
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top