Jump to content

Bernard

Members
  • Content Count

    68
  • Joined

  • Last visited

Everything posted by Bernard

  1. Hi, Here is a working example TM4C129 using Enrf24 library /* Tiva launchpad connected TM4C129 nRF24L01 RX SPI module 2 25/06/2014 */ #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> Enrf24 radio(PE_0,PE_2,PE_1); // CE, CSN, IRQ + SCK/MOSI/MISO ==> PD_3/PD_0/PD_1 const uint8_t rxaddr[] = { 0xF0,0xF0,0xF0,0xF0,0xE1 }; unsigned long prev_time; void setup() { Serial.begin(9600); Serial.flush(); SPI.setModule(2); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); radio.begin(); // Defaults 1Mbps, channel 0, max TX power dump_radio_status_to_serialport(radio.radioState()); radio.setRXaddress((void*)rxaddr); radio.enableRX(); // Start listening delay(100); } void loop() { char inbuf[33]; delta_set(); while (!radio.available(true)&& delta_get()<1000); if (radio.read(inbuf)) { Serial.println(inbuf); } } void delta_set() { prev_time = millis(); } // TimeOut unsigned long delta_get() { unsigned long time; unsigned long delta; time = millis(); if (time < prev_time) { // TimeOut delta = 0xffffffff - prev_time + time + 1; } else { delta = time - prev_time; } return delta; } void dump_radio_status_to_serialport(uint8_t status) { Serial.print("Enrf24 radio transceiver status: "); switch (status) { case ENRF24_STATE_NOTPRESENT: Serial.println("NO TRANSCEIVER PRESENT"); break; case ENRF24_STATE_DEEPSLEEP: Serial.println("DEEP SLEEP <1uA power consumption"); break; case ENRF24_STATE_IDLE: Serial.println("IDLE module powered up w/ oscillators running"); break; case ENRF24_STATE_PTX: Serial.println("Actively Transmitting"); break; case ENRF24_STATE_PRX: Serial.println("Receive Mode"); break; default: Serial.println("UNKNOWN STATUS CODE"); } } TX is MSP430 + DHT22 sending humidity and temperature Salutations Bernard
  2. Hi everyone, I have just received TM4C129 evaluation board and test with this program I have found on google. #include <Ethernet.h> // MAC address from Ethernet shield sticker under board byte mac[] = { 0x00, 0x1A, 0xB6, 0x02, 0xB1, 0x27 }; IPAddress ip(192,168, 0, 13); // IP address, may need to change depending on network EthernetServer server(80); // create a server at port 80 void setup() { Ethernet.begin(mac, ip); // initialize Ethernet device server.begin(); // start to listen for clients } void loop() { EthernetClient client = server.available(); // try to get client if (client) { // got client? boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { // client data available to read char c = client.read(); // read 1 byte (character) from client // last line of client request is blank and ends with \n // respond to client only after last line received if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); client.println(); // send web page client.println("<!DOCTYPE html>"); client.println("<html>"); client.println("<head>"); client.println("<title>Tiva Web Page</title>"); client.println("</head>"); client.println("<body>"); client.println("<h1>Hello from Tiva connected!</h1>"); client.println("<p>A web page from the Tiva server</p>"); client.println("</body>"); client.println("</html>"); break; } // every line of text received from the client ends with \r\n if (c == '\n') { // last character on line of received text // starting new line with next character read currentLineIsBlank = true; } else if (c != '\r') { // a text character was received from client currentLineIsBlank = false; } } // end if (client.available()) } // end while (client.connected()) delay(1); // give the web browser time to receive the data client.stop(); // close the connection } // end if (client) } When I connect the server for the first time with firefox, everything is ok, but after no success. I have to reset LM4C129. Do I miss something to make server permanently listening ? Thank you for help Salutations
  3. Hi, Months ago I ordered this booster pack ( 2.2 240x320 LCD V2 )and so far I haven't used it. I would like to know if it is CC3200 compatible. I Dont want to plug it on cc3200 board, just wire it but I do not understand this BP pinout. Can someone help me Thanks and salutations.
  4. Bernard

    Energia bug in Blink without delay tutorial

    Hi, May be this help : http://playground.arduino.cc/Code/TimingRollover Salutations
  5. Hi, Ethernet example " EthernetWebServer " doesn't compile under Energia 013 here is error message : In file included from awebserver.ino:8:0: C:\Users\Nardo\energia-0101E0013\hardware\lm4f\libraries\Ethernet/Ethernet.h:12:28: error: redefinition of 'const IPAddress INADDR_NONE' In file included from C:\Users\Nardo\energia-0101E0013\hardware\lm4f\libraries\Ethernet/Ethernet.h:8:0, from awebserver.ino:8: C:\Users\Nardo\energia-0101E0013\hardware\lm4f\cores\lm4f/IPAddress.h:73:17: error: 'const IPAddress INADDR_NONE' previously declared here Under Energia012 it compiles and runs ok. Thank you and Salutations Bernard.
  6. Hi, here is a Timer based blink using TimerIntRegister : /***************************** * LM4F120 - timer based blink * Using TimerIntRegister * 80 Mhz clock *****************************/ #include "inc/hw_ints.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/timer.h" void initTimer() { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); // 32 bits Timer TimerIntRegister(TIMER0_BASE, TIMER_A, Timer0Isr); // Registering isr ROM_TimerEnable(TIMER0_BASE, TIMER_A); ROM_IntEnable(INT_TIMER0A); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); } void Timer0Isr(void) { ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt digitalWrite(RED_LED, digitalRead(RED_LED) ^ 1); // toggle LED pin } void setup() { Serial.begin(9600); pinMode(RED_LED,OUTPUT); initTimer(); } void loop() { unsigned long ulPeriod; unsigned int Hz = 5; // frequency in Hz ulPeriod = (SysCtlClockGet() / Hz)/ 2; ROM_TimerLoadSet(TIMER0_BASE, TIMER_A,ulPeriod -1); while (1) { Serial.println("While timer is running ..."); delay(100); } } This compiles ok but I don' get the success message and I have to press reset button or sometimes unplug and replug the board to have it working. That means the code is uploaded. All my other codes compile and upload ok, just a problem with IntRegister ( Timer, Gpio ..) I am not skilled enough to understand what is going wrong so if someone could test this code and tell me what is it from his part. I posted the same question on Energia forum ( a mistake ) and I realize it wasn't the right place, I apologize for that. Regards Bernard
  7. Hi, I would like to centralize several RF sensors on TM4C129 and make a web server, so I write this simple sketch ( may be too simple) But, Serial.println("inbuf"); doesn't work and client.print(inbuf); works once. /* Tiva launchpad connected TM4C129 nRF24L01 RX SPI module 1 26/06/2014 */ #include <Ethernet.h> #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> byte mac[] = { 0x00, 0x1A, 0xB6, 0x02, 0xB1, 0x27 }; byte ip[] = { 192,168,0, 13 }; EthernetServer server(80); Enrf24 radio(PE_0,PE_2,PE_1); // CE, CSN, IRQ + SCK/MOSI/MISO ==> PB_5/PE_4/PE_5 const uint8_t rxaddr[] = { 0xF0,0xF0,0xF0,0xF0,0xE1 }; unsigned long prev_time; void setup() { Serial.begin(9600); Serial.flush(); Ethernet.begin(mac, ip); server.begin(); SPI.setModule(1); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); radio.begin(); // Defaults 1Mbps, channel 0, max TX power dump_radio_status_to_serialport(radio.radioState()); radio.setRXaddress((void*)rxaddr); radio.enableRX(); // Start listening delay(100); } //**************************** Main loop *************************************** void loop() { char inbuf[33]; delta_set(); Serial.println("Loop begin"); // debug while (!radio.available(true)&& delta_get()<1000); if (radio.read(inbuf)) { Serial.println("inbuf"); } //Listen to client (browser WEB) delay(100); EthernetClient client = server.available(); if (client) { boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); client.println(); client.println("<!DOCTYPE html>"); client.println("<html>"); client.println("<head>"); client.println("<title>Domotic</title>"); client.println("<meta http-equiv=\"refresh\" content=\"30\" >"); client.println("</head><body bgcolor=\"#000000\" text=\"#ffffff\" link=\"#0000ff\" vlink=\"#0000ff\" alink=\"#ff0000\">"); client.print("<h1>TM4C129 web server</h1><h2>Temperature</h2>"); client.print("Humidity and temperature = "); client.print(inbuf); client.print("<br>"); client.println("(update 30s)"); client.println("<br>"); client.println("</html>"); client.stop(); } } } Serial.println("End loop"); // debug } //************************** End main loop ***************************************** void delta_set() { prev_time = millis(); } // TimeOut unsigned long delta_get() { unsigned long time; unsigned long delta; time = millis(); if (time < prev_time) { // TimeOut delta = 0xffffffff - prev_time + time + 1; } else { delta = time - prev_time; } return delta; } void dump_radio_status_to_serialport(uint8_t status) { Serial.print("Enrf24 radio transceiver status: "); switch (status) { case ENRF24_STATE_NOTPRESENT: Serial.println("NO TRANSCEIVER PRESENT"); break; case ENRF24_STATE_DEEPSLEEP: Serial.println("DEEP SLEEP <1uA power consumption"); break; case ENRF24_STATE_IDLE: Serial.println("IDLE module powered up w/ oscillators running"); break; case ENRF24_STATE_PTX: Serial.println("Actively Transmitting"); break; case ENRF24_STATE_PRX: Serial.println("Receive Mode"); break; default: Serial.println("UNKNOWN STATUS CODE"); } } Any help would be appreciated. Salutations. Bernard
  8. Bernard

    TM4C129 +nRF24l01 web server problem

    I think it's true, although I added a 10uF cap, sometimes the program freeze when server get a client and need more power. I will try a 47uF. To be continued ... Salutations
  9. Bernard

    TM4C129 +nRF24l01 web server problem

    Hi, Finaly everything is ok .. a 10uF on the nRF24l01 breakout !!! Sorry for the inconvenience caused. Best regards Bernard
  10. Bernard

    TM4C129 +nRF24l01 web server problem

    @spirillis : thanks for replying. Yes Internet part works when I comment out Enrf24-related items. When I comment out //Ethernet.begin(mac, ip); //server.begin(); radio is ok and I get DHT22 values. Another clue, Resetting the TM4C129 board several times .. sometimes I cans see DHT22 values : copy of terminal with loop debug : Enrf24 radio transceiver status: DEEP SLEEP <1uA power consumption Loop begin <---- nada Enrf24 radio transceiver status: DEEP SLEEP <1uA power consumption Loop begin <---- nada Enrf24 radio transceiver status: DEEP SLEEP <1uA power consumption Loop begin 41.5---25.2 <----- good values miracle !!! if End Loop Loop begin salutations
  11. Bernard

    TM4C129 +nRF24l01 web server problem

    Hi, Sorry for my previous post, better to forget it . Here is another more clear I hope in order to explain my problem /* TM4C129 SPI module 1 */ #include <Ethernet.h> #include <Enrf24.h> #include <nRF24L01.h> #include <SPI.h> Enrf24 radio(PE_0,PE_2,PE_1); // CE, CSN, IRQ + SCK/MOSI/MISO ==> PB_5/PE_4/PE_5 const uint8_t rxaddr[] = { 0xF0,0xF0,0xF0,0xF0,0xE1 }; unsigned long prev_time; byte mac[] = { 0x00, 0x1A, 0xB6, 0x02, 0xB1, 0x27 }; IPAddress ip(192,168,0, 13); EthernetServer server(80); void setup(){ Serial.begin(115200); Serial.flush(); Ethernet.begin(mac, ip); server.begin(); SPI.setModule(1); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); radio.begin(); // Defaults 1Mbps, channel 0, max TX power dump_radio_status_to_serialport(radio.radioState()); radio.setRXaddress((void*)rxaddr); radio.enableRX(); // Start listening delay(200); } void loop(){ char inbuf[48]; delta_set(); Serial.println("Loop begin"); while (!radio.available(true)); //&& delta_get()<1000); Serial.println("before if"); if (radio.read(inbuf)) { Serial.println(inbuf); Serial.println("if"); } listenForEthernetClients(); Serial.println("End Loop"); } void listenForEthernetClients() { EthernetClient client = server.available(); if (client) { Serial.println("Got a client"); boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); if (c == '\n' && currentLineIsBlank) { client.println(); client.print("degreesC,25"); // just for test client.print(", "); client.print("Humidity,60"); // idem client.print(", "); client.print("millibar,1018"); // idem break; } if (c == '\n') { currentLineIsBlank = true; } else if (c != '\r') { currentLineIsBlank = false; } } } delay(1); client.stop(); } } void dump_radio_status_to_serialport(uint8_t status) { Serial.print("Enrf24 radio transceiver status: "); switch (status) { case ENRF24_STATE_NOTPRESENT: Serial.println("NO TRANSCEIVER PRESENT"); break; case ENRF24_STATE_DEEPSLEEP: Serial.println("DEEP SLEEP <1uA power consumption"); break; case ENRF24_STATE_IDLE: Serial.println("IDLE module powered up w/ oscillators running"); break; case ENRF24_STATE_PTX: Serial.println("Actively Transmitting"); break; case ENRF24_STATE_PRX: Serial.println("Receive Mode"); break; default: Serial.println("UNKNOWN STATUS CODE"); } } void delta_set() { prev_time = millis(); } // TimeOut unsigned long delta_get() { unsigned long time; unsigned long delta; time = millis(); if (time < prev_time) { // TimeOut delta = 0xffffffff - prev_time + time + 1; } else { delta = time - prev_time; } return delta; } nRF24L01 alone works ok but when I add the Ethernet part I can't get received values. The loop freeze on while (!radio.available(true)); I don't know why and I am a bit lost. Thanks for help. Best regards Bernard
  12. Bernard

    TM4C129 nRF24L01 RX working example

    Hi again, I forgot to post the TX side : /* MSP 430g2553 TX DHT22 25/06/2014 */ #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> #include <DHT22_430.h> #define DHTPIN P1_4 DHT22 mySensor(DHTPIN); Enrf24 radio(P2_0, P2_1, P2_2); // P2.0=CE, P2.1=CSN, P2.2=IRQ const uint8_t txaddr[] = { 0xF0,0xF0,0xF0,0xF0,0xE1 }; boolean flag = 0; void dump_radio_status_to_serialport(uint8_t); void setup() { Serial.begin(9600); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); // MSB-first mySensor.begin(); radio.begin(); // Defaults 1Mbps, channel 0, max TX power //radio.setCRC(1,1); radio.setTXaddress((void*)txaddr); } void loop() { char str[16]; long h = mySensor.humidityX10(); long t = mySensor.temperatureX10(); flag = mySensor.get(); if (!flag) { radio.print("DHT error"); } else{ sprintf(str, "%ld",h/10); radio.print(str); radio.print("."); sprintf(str, "%ld",h%10); radio.print(str); radio.print("---"); sprintf(str, "%ld",t/10); radio.print(str); radio.print("."); sprintf(str, "%ld",t%10); radio.print(str); radio.flush(); // Force transmit (don't wait for any more data) } delay(1000); } My project is to centrally manage several rf sensors on Tiva connected board and make a web server. I have spent many time to add the Ethernet part in the loop and so far no success ... any help would be appreciate Salutations Bernard
  13. Hello, Here is a ino file that allow to display temperature from LM4F120 internal sensor. It is based on example from TI workbook , ported a la mode Energia. Nothing spectacular. I am slowly learning ARM and I wanted to share. /* Read internal temperature sensor of LM4F120 Stellaris Launchpad Example from TI LM4F120 workbook A la mode Energia */ #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "Energia.h" unsigned long ulADC0Value[4]; volatile unsigned long ulTempAvg; volatile unsigned long ulTempValueC; volatile unsigned long ulTempValueF; void setup() { Serial.begin(9600); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS); // 250 ADCSequenceDisable(ADC0_BASE, 1); ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 1); } void loop() { ADCIntClear(ADC0_BASE, 1); ADCProcessorTrigger(ADC0_BASE, 1); while(!ADCIntStatus(ADC0_BASE, 1, false)) { } ADCSequenceDataGet(ADC0_BASE, 1, ulADC0Value); ulTempAvg = (ulADC0Value[0] + ulADC0Value[1] + ulADC0Value[2] + ulADC0Value[3] + 2)/4; ulTempValueC = (1475 - ((2475 * ulTempAvg)) / 4096)/10; ulTempValueF = ((ulTempValueC * 9) + 160) / 5; Serial.println(ulTempValueC); delay(300); } Salutations. Bernard
  14. Bernard

    My first attempt TM4C129

    Hi, Thank you energia for reply. I just tried your example under Firefox ubuntu and it perfectly works. I don't know why it doesn't work under Firefox windows .. not a big problem. Salutations
  15. Bernard

    MSP430G2553 and Rotary encoder

    Hi, Thank you very much Chicken.. it works perfectly Bernard
  16. Hello, I am trying to use rotary library for my VFO ad9850. Originally writen for Arduino I just changed PCINT for PORT2_VECTOR interrupt. so far can say it almost works but I get some issues I cannot understand Here is my test code : /* encoder_test.ino Energia 011 MSP430G2553 launchpad ver 1.5 Windows 7 Rotary encoder KY-040 */ #include <msp430g2553.h> #include "rotary.h" Rotary r = Rotary(P2_1, P2_2); void setup() { Serial.begin(9600); P2DIR &= ~(BIT1 + BIT2); P2IES = BIT1 + BIT2 ; //high to low transition P2OUT |= BIT1 + BIT2; P2REN = BIT1 + BIT2; P2IE = BIT1 + BIT2; P2IFG &= ~BIT1 + BIT2; _BIS_SR(GIE); } void loop() { } #pragma vector=PORT2_VECTOR __interrupt void port_2 (void) { unsigned char result = r.process(); if (result) { Serial.println(result == DIR_CW ? "Right" : "Left"); } P2IFG &= ~BIT1 + BIT2; // P2.1 P2.2 interrupt flag cleared } rotary.h /* * Rotary encoder library for Arduino. */ #ifndef rotary_h #define rotary_h #include "Energia.h" // Enable this to emit codes twice per step. #define HALF_STEP // Values returned by 'process' // No complete step yet. #define DIR_NONE 0x0 // Clockwise step. #define DIR_CW 0x10 // Anti-clockwise step. #define DIR_CCW 0x20 class Rotary { public: Rotary(char, char); // Process pin(s) unsigned char process(); private: unsigned char state; unsigned char pin1; unsigned char pin2; }; #endif rotary.cpp /* Rotary encoder handler for arduino. v1.1 * * Copyright 2011 Ben Buxton. Licenced under the GNU GPL Version 3. * Contact: bb@cactii.net * * A typical mechanical rotary encoder emits a two bit gray code * on 3 output pins. Every step in the output (often accompanied * by a physical 'click') generates a specific sequence of output * codes on the pins. * * There are 3 pins used for the rotary encoding - one common and * two 'bit' pins. * * The following is the typical sequence of code on the output when * moving from one step to the next: * * Position Bit1 Bit2 * ---------------------- * Step1 0 0 * 1/4 1 0 * 1/2 1 1 * 3/4 0 1 * Step2 0 0 * * From this table, we can see that when moving from one 'click' to * the next, there are 4 changes in the output code. * * - From an initial 0 - 0, Bit1 goes high, Bit0 stays low. * - Then both bits are high, halfway through the step. * - Then Bit1 goes low, but Bit2 stays high. * - Finally at the end of the step, both bits return to 0. * * Detecting the direction is easy - the table simply goes in the other * direction (read up instead of down). * * To decode this, we use a simple state machine. Every time the output * code changes, it follows state, until finally a full steps worth of * code is received (in the correct order). At the final 0-0, it returns * a value indicating a step in one direction or the other. * * It's also possible to use 'half-step' mode. This just emits an event * at both the 0-0 and 1-1 positions. This might be useful for some * encoders where you want to detect all positions. * * If an invalid state happens (for example we go from '0-1' straight * to '1-0'), the state machine resets to the start until 0-0 and the * next valid codes occur. * * The biggest advantage of using a state machine over other algorithms * is that this has inherent debounce built in. Other algorithms emit spurious * output with switch bounce, but this one will simply flip between * sub-states until the bounce settles, then continue along the state * machine. * A side effect of debounce is that fast rotations can cause steps to * be skipped. By not requiring debounce, fast rotations can be accurately * measured. * Another advantage is the ability to properly handle bad state, such * as due to EMI, etc. * It is also a lot simpler than others - a static state table and less * than 10 lines of logic. */ #include "Energia.h" #include "rotary.h" /* * The below state table has, for each state (row), the new state * to set based on the next encoder output. From left to right in, * the table, the encoder outputs are 00, 01, 10, 11, and the value * in that position is the new state to set. */ #define R_START 0x0 #ifdef HALF_STEP // Use the half-step state table (emits a code at 00 and 11) #define R_CCW_BEGIN 0x1 #define R_CW_BEGIN 0x2 #define R_START_M 0x3 #define R_CW_BEGIN_M 0x4 #define R_CCW_BEGIN_M 0x5 const unsigned char ttable[6][4] = { // R_START (00) { R_START_M, R_CW_BEGIN, R_CCW_BEGIN, R_START } , // R_CCW_BEGIN { R_START_M | DIR_CCW, R_START, R_CCW_BEGIN, R_START } , // R_CW_BEGIN { R_START_M | DIR_CW, R_CW_BEGIN, R_START, R_START } , // R_START_M (11) { R_START_M, R_CCW_BEGIN_M, R_CW_BEGIN_M, R_START } , // R_CW_BEGIN_M { R_START_M, R_START_M, R_CW_BEGIN_M, R_START | DIR_CW } , // R_CCW_BEGIN_M { R_START_M, R_CCW_BEGIN_M, R_START_M, R_START | DIR_CCW } , }; #else // Use the full-step state table (emits a code at 00 only) #define R_CW_FINAL 0x1 #define R_CW_BEGIN 0x2 #define R_CW_NEXT 0x3 #define R_CCW_BEGIN 0x4 #define R_CCW_FINAL 0x5 #define R_CCW_NEXT 0x6 const unsigned char ttable[7][4] = { // R_START { R_START, R_CW_BEGIN, R_CCW_BEGIN, R_START } , // R_CW_FINAL { R_CW_NEXT, R_START, R_CW_FINAL, R_START | DIR_CW } , // R_CW_BEGIN { R_CW_NEXT, R_CW_BEGIN, R_START, R_START } , // R_CW_NEXT { R_CW_NEXT, R_CW_BEGIN, R_CW_FINAL, R_START } , // R_CCW_BEGIN { R_CCW_NEXT, R_START, R_CCW_BEGIN, R_START } , // R_CCW_FINAL { R_CCW_NEXT, R_CCW_FINAL, R_START, R_START | DIR_CCW } , // R_CCW_NEXT { R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START } , }; #endif /* * Constructor. Each arg is the pin number for each encoder contact. */ Rotary::Rotary(char _pin1, char _pin2) { // Assign variables. pin1 = _pin1; pin2 = _pin2; // initialisation in the main // Initialise state. state = R_START; } unsigned char Rotary::process() { // Grab state of input pins. unsigned char pinstate = (digitalRead(pin2) << 1) | digitalRead(pin1); // Determine new state from the pins and state table. state = ttable[state & 0xf][pinstate]; // Return emit bits, ie the generated event. return state & 0x30; } Sometimes I get LEFT among RIGHT et vice versa . Turning knob very fast freezes the program. Any help would be appreciate. Salutations Bernard
  17. Bernard

    Test

    Testing Tapatalk Envoy
  18. Bernard

    Code::Blocks + mspgcc how-to.

    Hi, Compiling template I get this error message #include int main(){ return 0;} ..\main.c|1|error: #include expects "FILENAME" or <FILENAME>| ||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===| CodeBlock version : 12.11 Any idea to help me ? Salutations
  19. Hi, Thank you for this nice library. works here on stellaris. Which pins do you suggest on MSP430G2553 ? Thank you Salutations
  20. Bernard

    dtostrf in Energia

    Hello, I finally got sprintf working. I am able to send and receive datas from BMP085 here is my working code: /* Stellaris LM4F120 nRF24L01 TX BMP085 SPI module 2 I2C module 0 21/01/2014 */ #include<Wire.h> #include "BMP085_t.h" // in a IDE tab .. template from chicken #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> Enrf24 radio(PA_5,PA_6,PA_7); // CE, CSN, IRQ + SCK/MOSI/MISO ==> PB_4/PB_7/PB_6 char txaddr[] = {'d','e','v','-','0','\0'}; BMP085<0> PSensor; void setup() { Serial.begin(9600); Wire.setModule(0); Wire.begin(); // initialize I2C that connects to sensor PSensor.begin(); // initalize pressure sensor SPI.setModule(2); // SPI 2 SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); radio.begin(); // Defaults 1Mbps, channel 0, max TX power radio.setTXaddress((void*)txaddr); } //************************************************************************ void loop() { char str[5]; long value; PSensor.refresh(); // read sensor data BMP085 PSensor.calculate(); value = ((PSensor.pressure+50)/100); sprintf(str, "%.2d", value); radio.print(str); radio.print("---"); value = (PSensor.temperature/10); sprintf(str, "%.2d", value); radio.print(str); radio.flush(); // Force transmit (don't wait for any more data) delay(1000); } //************************************************************************* LM4F120 on the receiver side. Thank you all who helped me. Salutations
  21. Bernard

    dtostrf in Energia

    Hi, I am sorry, sprintf is ok now, I did not allocate enough for buffer . Thank you and salutations.
  22. Bernard

    dtostrf in Energia

    Hi, @@energia : Thank you for information. I have tried to use sprintf but, when using it, program crashes and I don't know why . I have found on the web itoa code that works . @@spirilis : thank you very much for this nice library , it helps me a lot in my wireless domotic project. Salutations.
  23. Bernard

    dtostrf in Energia

    Hi again, I have found another way to convert float to string : void setup() { Serial.begin(9600); } char buffer[12]; void loop() { float value = 150.51; itoa(int(value), buffer, 10); int dec = (value - (int)value) * 100; itoa(abs(dec), buffer, 10); Serial.println( value); delay(1000); } It compiles on msp430G2553, F5529 but itoa is unknown when compiling on LM4F120 and Tiva C Salutations
×