Maceraperest 0 Posted May 9, 2016 Share Posted May 9, 2016 Do you understand the port salute code ? #define TCD_SH 0x01 //====> What means this port #define TCD_CLK1 0x02 #define TCD_CLK2 0x04 #define TCD_BT 0x08 #define TCD_RS 0x10 void tcd1201d_setup() { DDRB = 0x1F; } unsigned char tcd1201d_out[1047]; int tcd1201d_dark; void tcd1201d_read() { PORTB = TCD_SH | TCD_CLK1; PORTB = TCD_CLK1; for (int i = 0; i < 1047; ++i) { PORTB = TCD_CLK1; PORTB = TCD_RS | TCD_CLK1; PORTB = TCD_RS | TCD_BT | TCD_CLK1; PORTB = TCD_BT | TCD_CLK1; PORTB = TCD_BT | TCD_CLK2; // Could read here too, but we'll skip half of them. PORTB = TCD_CLK2; PORTB = TCD_RS | TCD_CLK2; PORTB = TCD_RS | TCD_BT | TCD_CLK2; PORTB = TCD_BT | TCD_CLK2; PORTB = TCD_BT | TCD_CLK1; int v = analogRead(A0); if (i == 14) tcd1201d_dark = v; if (v > tcd1201d_dark) v = tcd1201d_dark; v = (tcd1201d_dark - v) / 2; if (v > 255) v = 255; tcd1201d_out[i] = v; } } void setup() { analogReference(DEFAULT); tcd1201d_setup(); Serial.begin(115200); } void loop() { tcd1201d_read(); tcd1201d_read(); for (int i = 0; i < 1047; ++i) { Serial.print(tcd1201d_out[i], HEX); } Serial.println(); } tcd1201.ino Quote Link to post Share on other sites
Maceraperest 0 Posted May 9, 2016 Author Share Posted May 9, 2016 Convert to energia please... Quote Link to post Share on other sites
Rei Vilo 695 Posted May 9, 2016 Share Posted May 9, 2016 Help yourself with general guide on porting arduino libraries to energia howto: porting libraries - some help needed Some Misconceptions about Libraries Maceraperest 1 Quote Link to post Share on other sites
Maceraperest 0 Posted May 9, 2016 Author Share Posted May 9, 2016 #define TCD_SH 0x01 ====> Does anyone know what this is port ? PE_4 or PB_2 =====> How to return Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.