Maceraperest 0 Posted June 23, 2016 Share Posted June 23, 2016 I do not know in converting from arduino energia Please help to translate this code; #define TCD_SH 0x01 #define TCD_CLK1 0x02 #define TCD_CLK2 0x04 #define TCD_BT 0x08 #define TCD_RS 0x10 void tcd1201d_setup() { DDRB = 0x1F; } //byte tcd1201d_out[1047]; 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; 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; Serial.print(","); byte v = analogRead(A0); //tcd1201d_out[i] = v; //Serial.print(tcd1201d_out[i]); //unsigned //Serial.print(i); //Serial.print(","); Serial.print(v); } Serial.println(); } void setup() { analogReference(DEFAULT); tcd1201d_setup(); Serial.begin(115200); } void loop() { tcd1201d_read(); } tcd1201d.ino Quote Link to post Share on other sites
Rei Vilo 695 Posted June 23, 2016 Share Posted June 23, 2016 Low level functions as registers aren't compatible between the AVR and TM4C platforms. Please use higher level functions; the Arduino framework acts as a hardware abstraction layer. In this specific case, the easier way is to go through the datasheet of the TCD1201D and develop the library from scratch. For more information on how to port from Arduino to Energia, please refer to Posting a Library for Energia/, Can I Use Libraries Written for Arduino with Energia/ and General Guide on Porting Arduino Libraries to Energia/. Quote Link to post Share on other sites
chicken 630 Posted June 23, 2016 Share Posted June 23, 2016 Probably not that hard to convert this small piece of code. Simply look for the proper replacements for DDRB (port direction) and PORTB (port output) registers. Look here for a start: http://users.ece.utexas.edu/~valvano/Volume1/E-Book/C6_MicrocontrollerPorts.htm Quote Link to post Share on other sites
chicken 630 Posted June 23, 2016 Share Posted June 23, 2016 Relevant thread on 43oh: http://forum.43oh.com/topic/7136-solved-writing-and-reading-the-values-of-an-8-bit-port-with-energia/ 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.