Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About drumanart

  • Rank
  1. Hello. I use since a couple of years a licensed version of BoostC C Compiler (Version 6.95). Now, as a plan to upgrade to a newer, actual, version and also to migrate to MPLAB-X (I use still MAPLAB 8.5 with LINUX and wine what works like a charm) I have a doubt: If I buy the C++ Compiler can I compile (re-use) code written for the BoostC C compiler version? In any case as I plan to go on with LINUX I suppose that I will have some issues to make SourceBoost work. Thanks Martin
  2. Hello. Code for 18F4420 At the beginning of my code I tell the preprocessor to activate the watch dog. #pragma DATA _CONFIG2H, _WDT_ON_2H & _WDTPS_2048_2H // WDTON, prescaler 1/2024. Is there a possibility to deactivate the watchdog while the code is running but not with _asm clrwdt? Thanks Martin
  3. Math Question

    Thanks for the LUT solution. As the compass works with 16bit resolution and I have to calculate, beside the heading, also pitch and roll (with an incorporated accelerometer) I thinks the easiest way is to send all raw data (6 bytes for the magnetometer and 6 bytes for the accelerometer) to the computer and solve the "big" calculation with the PC. I can do this quite straight forward with SuperCollider. The other thing is, as I mentioned above, that my browser shows rare signs if I lock at other threads: so, for example: ( for ( // ( for ) // &#41 for "; Any succestion Thanks Martin
  4. Hello, I made a small PCB for the LSM303 electronic compass. The unit communicates with a I2C protocol and I made my one software functions to communicate with the unit what works great. Now, to get something useful out of the row data I have to use some math. Following the app notes of the LSM303 I have to calculate: Heading = arctan (Yh/Xh) Is there a mathematic library in SourceBoost. I work with a licend 6,95 Version. The other thing is that my browser (Chromium with Linux) want show the special signes from other threads correctly. My browser shows: ( for ( // ( for ) // &#41 for "; and so on .. It is difficult to read the code. Thanks Martin (
  5. Ok, I respond to myself: As nobody in the forum seems to run MPLABX IDE under Linux (UBUNTU) and before inverting for a new programmer ICD3 (ICD2 want work with MPLABX IDE ) and before purchasing a new version of SourceBoost (with drivers for MPLABX IDE) I installed PIKLAB IDE. IT WORKS GREAT and my ICD2 clone runs even faster then ever in MPLAB IDE under WIndows. Martin
  6. Hello. I use UBUNTU (LINUX) as an OS and run, using wine, MPLAB IDE 8.5 with a licensed SourceBoost v.6.95 This works fine but is a little slow. No, since Microchip lanced the MPLAB X IDE there is also a version for LINUX and I red that SourceBoost v.7.05 has the drivers to run the program with the new environment. Does this works also on a LINUX (UBUNTU) without fiddling with wine, and did someone install it successfully? ( I can't find any topics). Thanks Martin
  7. Jorge, I found the bug, I had the T1CON, 3 (T1OSCEN) flag enabled. This is why the program always jumped to the void interrupt(void ) function. Both, the TMR0 and TMR1 timers, as well as the SSPIF flag are set as high priority and I handle them using the void interrupt(void ) function and the program works great. If I put an oscilloscope at the PW output, even in receiving continuous data stream from the wireless SPI unit (nRF24L01 is great), the puls-with is not affected at all. I did a little trial to manage the SPI in pooling the BF flag and also this works. As I have now the abilities to handel18 stepper motors the last thing I need to do is to set up the CCP module for two other PW to use with two independent servo motors. I suppose I will be in troubles shortly because the SPI module also uses the TMR2 oscillator. Thanks for you help. Martin
  8. Oh yes, the SSPIP is flag is the PIR1,3 and the TMR1F the PIR1,0. Yesterday I tried to find the failure of my interrupt mess without having success. Still, as soon as I start the timers (TMR0, TMR1) fto run the PW the communication with the SPI unit fails. Today I will handle the SPI pooling the SSPIF in the main function. Would it be also possible to use the SSPSTAT, BF (buffer full) flag to handle the SPI module? Thanks for your passion. Martin
  9. Yeep Jorge. Thanks for the advise of the AND and OR gates graphics at page 92 of the 18Fxx data-sheet this is helpful for understanding of interrupts. As I had the PW for two servos with TMR0, TMR1 working really nicely and on the other hand the SPI unit (the Nordic 24L01 wireless radio) ) using another program was working fantastic (in my opinion) I didn't expect to have this troubles. I'm sure the mess is already at the SPI interrupt PIR1,SSPIF. Probably I forgot to clear somewhere the SSPIF as I did with the TMR1IF flag (this is why I forced the GIE flag to 1) . I suppose this messes up the further interrupt routines. I'll get there, for sure ..... kind regards Martin
  10. Hi Jorge. So, I assume only if the IPEN of the RCON register is set the High/Low priority bits are valid and an interrupt_low function is activated. Now, could I handle the PW routine with the TMR0 and TMR1 flags as low priority interrupts in the interrupt_low function and handle the INT2IF and the SSPIF for the ISP unit as high priority interrupts? ( I don't find a way to set TMR1 as low priority, nor the SSPIF) Or is it easier to set the RCON bit as 0 and work in PIC16CXXX Compatibility mode. What is the standard way if one creates PW with timers and have a ISP unit connected. Thanks Martin I
  11. The thing is slightly more complex, as the program creates two PW, with timer0 and timer1. At start up I have to set the GIE & PEIE to configure the ISP module (wirless radio nRF24L01). I changed the messy code following your advice and I can receive wireless data from the nRF24L01, but as soon as I start the timers (the disabled code underneath) the INT2IF want get high anymore and I can't receive wireless data any more. So, either the PW works or the nRF24L01 works. Still there is a missmatch. Thanks Martin void interrupt(void){ if (spi_interrupt){ spi_handle_interrupt(); } else if (int2if){ int2if = 0; // IRQ of nRF24L01, if low reads data buffer. RX_TX_nRF(); } //reload 20ms periode time. else if (tmr0if){ tmr0l = 100; // Value for TIMER0: 100d.= 20ms - 50Hz tmr0if = false; // Clear INTCON overflow bit.(TMR0) count = 1; PW_0 = true; // Strats SERVO 1 pulse. tmr1on = true ; // Enable TIMER1. tmr1if = false; // PIR1 (clear timer1 overflow flag) tmr1h = TIME1_FIX; // Load fixed value into TIMER1 register; tmr1l = TIME_ON1; // Variable value for Servor 1. } else if ((tmr1if) && (count == 1)){ PW_0 = false; // Stops SERVO 1 pulse. PW_1 = true; // Starts SERVO 2 pulse. tmr1if = false; // PIR1 (clear timer1 overflow flag). tmr1h = TIME1_FIX; // Fixed value; tmr1l = TIME_ON2; // Value to be loaded for Servor 2. count++; } else if ((tmr1if) && (count == 2)){ PW_1 = false; // Stops SERVO 2 pulse. tmr1on = false; // disable TIMER1. count = 0; } gie = true; // re-enable GIE. } void main() { init(); // device and peripheral initialisation. unsigned char get_byte; char count = 0x02; nrf_rx_mode(); // nRF receiver mode & power up. peie = false; gie = false; // disable all interrupts. intcon2 = INTCON2_CONF; // 00000000b Pullup enabled, Interrupt RB2 falling edge, Low priority. intcon3 = INTCON3_CONF; // 00010000b RB2, INT2IE, enabled, INT2IP disabled. peie = true; // peripheral interrupts inabled. int2if = false; // clear a possible pending interrupt. // sets the timers for the PW modulation. // if I enable this code the wireless module wont work, but the PW works. /*t0con = TIME0_CONF; // Timer0 enabled, precaler set to 1/128, 8 bit and load tmr0l = TIMEFR_VAL; // Value for TIMER0: 100d.= 20ms - 50Hz. t1con = TIME1_CONF; // 00111000b, T1CON, 1/8 presc. Timer1 disabled. tmr1h = TIME1_FIX; // 11111110b // to get the above times in ms. (8 bit) tmr1if = false; // PIR1 (clear timer1 overflow flag). pie1 = PIE1_CONF; // TMR1 overflow bit enabled & EUSART interrupt enabled. tmr0ie = true; // timer 0 ext. interrupt enabled.*/ gie = true; // start all interrupts. while (1){ PW_LED_OnOff(); // toggle LED Off. } } // // // function sends the received data to USART void RX_TX_nRF(){ unsigned char get_byte; char count = 0x02; PW_LED_OnOff(); // DEBUG ONLY. nrf_read_fifo(); // reads data from the payload. while (count < 5){ // control function, prints to serial port. get_byte = nrf_get_byte(count); // gets the data from data[] array. serial_printf(get_byte); // print the return value to the terminal. count++; } count = 0x02; // set the pointer in spi_exchange function. nrf_reset_status(); // clear nrf24L01 status reg. } // // void init(){ osccon = 01110000b; // internal oscillator at 8 MHz. while (!iofs); // iofs OSCCON stable bit. adcon1 |= 0x0F; // All digital IO's, no analog ports required. trisa = 10111111b; // RA6, ID_LED. trisb = 00000100b; // RB0, RB1 PW out. RB2 IRQ for nRF24L01. trisc = 11000000b; // RC6, RC7 RX; RC0 LED white, RC4 LED yellow. portb = 0x00; gie = true; // set GIE & PEIE to configure the nRF24L01. peie = true; // Serial interface serial_init(34); // (51) 38400 baud; (34) 57600 baud; DEBUG, before: BRG = 25 (19200 baud at 8MHz). serial_printf("initializing serial port"); serial_print_lf(); // Wireless interface nrf_init(); // init the nRF24L01. serial_printf("nRF24L01 config done..."); serial_print_lf(); return; }
  12. Hello. I spent a entire afternoon in trying to get en interrupt on a PIC18F4420 on portb,2 working. At portb,2 I have the IRQ pin of an nRF24L01 attached. So, this pin drives low when data is received and I would like that the program jumps to the void interrupt(void) routine. For test purpose the program stays for ever in the interrupt function. With my code the int2if flag gets high before a change of portb,2 occurs, but the idea is that the interrupt happens if the pin is pulled down. To configure the PIC I made an init function: . void init(){ osccon = 01110000b; // internal oscillator at 8 MHz. while (!iofs); // iofs OSCCON stable bit. adcon1 |= 0x0F; // All digital IO's, no analog ports required. trisb = 00000100b; // PortB, RB2 In, used to provoke an interrupt. intcon = INTCON_CONF; // 11101000b, GIE/PEIE enabled, PortB interrupt on change enabled, TMR0IE enabled, rcon = RCON_CONF; // 00011100b, interrupt priority disabled. intcon3 = INTCON3_CONF; // 10010000b INT2IP enabled, RB2, INT2IE, enabled. intcon2 = INTCON2_CONF; // 00000001b Pullup enabled, Interrupt RB2 falling edge, High priority. } void interrupt(void){ char aux = portb; if (int2if){ // to see if something happens. while(1); } } Thanks Martin Interrupt_on Portb.c
  13. Hi Jorge. I have seen that you handle the RX data also in the ISR. Unfortunately your code want run in Sourceboost neither in MPLAB so (for me) it is not so easy to follow entirely your ideas. Somehow I understand that you resend data to the servos every 20ms, but I can't find where you handle the "Elapsed20ms" variable. Thanks Martin
  14. This is great, I just printed the code and I go into it this days. My two SERVOS work now quite nice, but still, my main problem is the data transmission. With my Easy Radio(ER400TRS) I have some problem to send packages of three bytes: "header" 0xFF; "channel" 0x00/0x01) and "data" 0x00 to 0xFF. So, the past weekend I made a new protocol sending only two bytes. 10 bits for the SERVO data and 6 bites for addressing. This works best until know. Probably I forget the EASY RADIO and do the wireless transfer with the NORDIC 24L01. This units allow sending packages until 32 bytes. Two month ago I made a small PCB with an accelerometer and a gyro sending 6 different data wireless to the computer. It works very stable and fast. Thanks a lot for your help Martin