Jump to content

sdujolo

EstablishedMember
  • Content Count

    96
  • Joined

  • Last visited

Everything posted by sdujolo

  1. Sorry what do you mean? I am not that experienced with C/C++
  2. I get a warning when I use delay_us(x); Device PIC18F4620 @ 40MHz Building... BoostC Optimizing C Compiler Version 6.60 (for PIC18 architecture) http://www.sourceboost.com Copyright© 2004-2006 Pavel Baranov Copyright© 2004-2006 David Hobday Caution: argument of 'delay_us' calls must have a value of 1 or more
  3. I configuration wizard for the fuse would be good to have so it reads the diffrent option from the .h file and the write your selection to your project.
  4. Many like my self like the use of bootloader but there are alot to choose of. Why to make one specially for boostc and for most targets the will be easy to configure and use? First for normal rs232 and the support for diffrent interfaces.
  5. Thanks for your answer I ended up in split it in two char see code below. Any better solution? void send_nexa_cmd(char cmd1, char cmd2) { char i,j; for (j = 0; j < 2; j++ ) { for (i = 0; i < 8; i++) { if ( test_bit(cmd1, i) ) { send_one(); }else { send_zero(); } } for (i = 0; i < 4; i++) { if ( test_bit(cmd2, i) ) { send_one(); }else { send_zero(); } } send_stop(); delay_ms(10); } Printf("OK\n\r"); }
  6. How to test a bit on a integer value? test_bit(var, num) is only works up to 8bit
  7. Take a look here http://www.lika.be/content/view/21/30/
  8. Download and use this one-wire example code. There are nop(); instruction you have to change depend on crystal frequency. I don´t know if the built in lib take care of the timing or if it just work on one crystal frequency? http://www.lika.be/content/view/21/30/ Here is also a function I wrote to get tempature data but it use the float libary(it´s not 100% tested). oo_temperature ReadTemperature( char lsb, char msb, char remain, char nr_count) { int temp_int; float frac_deg; oo_temperature data; temp_int = lsb/2; if ( msb == 0xFF ) temp_int -= 128; if ( nr_count != 0 ) frac_deg = float32_div( float32_from_int32( (nr_count-remain) ), float32_from_int32( nr_count ) ); else frac_deg = 0.25; frac_deg = float32_add( frac_deg, float32_from_int32( temp_int ) ); data.temp = float32_sub( frac_deg, 0.25 ); data.int_temp = float32_to_int32( data.temp ); data.decimal = float32_to_int32(float32_mul( float32_sub( data.temp, float32_from_int32( float32_to_int32_round_to_zero( data.temp ) ) ), 100)); if ( data.decimal < 0 ) data.decimal -= data.decimal*2; return data; }
  9. How to send float value to serial or lcd? Regards /Jörgen
  10. Hello I use this code from Lieven Hollevoet http://boostc.lika.be I have tested it on 16f876A and 18f4620. /Jörgen char eeprom_read(char address){ // Load address eeadr = address; // Point to EEPROM memory eecon1.EEPGD = 0; // 18F devices also need the CFGS bit to be cleared #ifdef CFGS eecon1.CFGS = 0; #endif // Read, data is available in eedata the next cycle. eecon1.RD = 1; // Return value return eedata; }
  11. Thanks for the float I have been waiting a long time for that. Regards /Jörgen
  12. Have you enabled interrupt priorities on the PIC18 (Set the IPEN bit)? Regards Dave <{POST_SNAPBACK}> Thanks Dave, I got it working now I had forget to clear TMR0IP. BR /Jörgen clear_bit(intcon2, TMR0IP); //TMR0 Overflow Interrupt Priority bit 1 = High priority 0 = Low priority
  13. You don't need to use the -swcs (SoftWare Call Stack) option to use the low priority interrupt. The low priority interrupt will just work. -swcs is normally used to setup stack usage when using Novo RTOS. If you did want to use it then the format is: -swcs 20 4 2 This give hardware stack usage of 20 in the main task before using software callstack, hardware stack usage of 4 in high priority interrupt before using software callstack, hardware stack usage of 2 in low priority interrupt before using software callstack. Regards Dave Regards Dave <{POST_SNAPBACK}> Hello Dave, I cut this code from the normal interrupt and paste it to the low intrrupt function and now is not working why? It is working when I have it in normal interrupt. Regards /Jörgen void interrupt_low( void ) { //Handle timer0 interrupt if( intcon & (1<<T0IF) ) { counter++; clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit } }
  14. Hello, I how to get interrupt_low to work on a PIC18? I have addet the switch -swcs s3 but that will not link? I Got error. Regards /Jörgen Linking... C:\Program\SourceBoost\boostlink.pic.exe /ld C:\Program\SourceBoost\lib libc.pic18.lib eeprom.obj MultiControl.obj oo.obj serial.obj adc.obj /t PIC18F4620 /d D:\Dev\Pic\MultiControlPic18 /p MultiControl -swcs s3 BoostLink Optimizing Linker Version 6.55 http://www.sourceboost.com Copyright© 2004-2006 Pavel Baranov Copyright© 2004-2006 David Hobday Failure Error: Failed to open:s3. Done
  15. Thanks Dave Regards /Jörgen
  16. Hello I am trying the Novo RTOS and i have some problem I like to run some code only if I get someting on the serial port but I cant understand how to do it. Here is the code I trying. #include <system.h> #include <novocfg_pic18t3e5ts1.h> #include <novo.h> #include "serial.h" #define hTask0 0 #define hTask1 1 #define hSemaphore 0 void interrupt( void ) { char input; // update system time every 4ms (actually is 204.8us x 20 = 4.096ms) static BYTE intDivider; if( ++intDivider == 20 ) { intDivider = 0; SysTimerUpdate(); } // USART received interrupt flag, received a character if (test_bit(pir1, RCIF) && test_bit(pie1,RCIE)) { if (test_bit(rcsta,OERR)) // comms overrun error { //temp = rcreg; // read register to throw away, might need to do something else as well? clear_bit(rcsta,CREN); set_bit(rcsta,CREN); } else { input = rcreg; // reads character SysSignalSemaphoreIsr( hSemaphore ); } // else no comms error } // if received char interrupt flag intcon.TMR0IF = 0; //clear TMR0 overflow flag } void InitTimer() { // configure Timer0 t0con.TMR0ON = 1; //enable timer t0con.T08BIT = 1; //set 8-bit mode t0con.T0CS = 0; // use internal clock t0con.PSA = 0; // use prescaler for timer 0 // so we get an interrupt around every 204.8us with 40MHz Clock // set pre-scaler to divide by 8 t0con.T0PS0 = 0; t0con.T0PS1 = 1; t0con.T0PS2 = 0; // enable interrupts set_bit( intcon, TMR0IE ); //enable TMR0 overflow bit set_bit( intcon, GIE ); } void InitIo() { trisb = 0x01; // leave bit 0 as input for bootloader lata = 0; adcon1 = 0x0F; // All ports as digital I/O (not analog I/O) //cmcon = 0x07; // Comparator mode for PORTA off. trisa = 0xFF; // PORTA as inputs // Serial interface serial_init(0x0A, 1); serial_printf("Starting...\r\n"); } void Task0() { while( 1 ) { // when semaphore is signalled we flash the LED Sys_WaitSemaphore( hSemaphore, EVENT_NO_TIMEOUT ); serial_printf("Task0\r\n"); Sys_Yield(); } } void Task1() { while( 1 ) { serial_printf("Task1\r\n"); Sys_Sleep( 20 ); Sys_Yield(); } } void main() { InitTimer(); InitIo(); SysInit(); SysCreateTask( hTask0, 2, Task0 ); SysCreateTask( hTask1, 2, Task1 ); SysStartTask( hTask0 ); SysStartTask( hTask1 ); while( 1 ) { Sys_Yield(); } }
  17. Hello Dave, How to get the full source? Regards /Jörgen
  18. isdigit, strncmp ect is not working after upgrade to V6.50 /Jörgen Building... BoostC Optimizing C Compiler Version 6.50 (for PIC16 architecture) http://www.sourceboost.com Copyright© 2004-2006 Pavel Baranov Copyright© 2004-2006 David Hobday Licensed to Jorgen Lodin under Single user Pro License for 1 node(s) Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited MultiControl.c D:\Dev\Pic\MultiControl\MultiControl.c(321:7): error: unknown identifier 'isdigit' D:\Dev\Pic\MultiControl\MultiControl.c(321:7): error: failed to generate expression D:\Dev\Pic\MultiControl\MultiControl.c(321:7): internal error: failed to generate 'if' expression D:\Dev\Pic\MultiControl\MultiControl.c(330:7): error: unknown identifier 'isdigit' D:\Dev\Pic\MultiControl\MultiControl.c(330:7): error: failed to generate expression D:\Dev\Pic\MultiControl\MultiControl.c(330:7): internal error: failed to generate 'if' expression D:\Dev\Pic\MultiControl\MultiControl.c(600:7): error: unknown identifier 'strncmp' D:\Dev\Pic\MultiControl\MultiControl.c(600:7): error: failed to generate expression D:\Dev\Pic\MultiControl\MultiControl.c(600:7): error: invalid operand 'strncmp( rx_queue, "AT+RELAY", 8) ' D:\Dev\Pic\MultiControl\MultiControl.c(600:41): error: failed to generate expression D:\Dev\Pic\MultiControl\MultiControl.c(600:41): internal error: failed to generate 'if' expression failure C:\Program\SourceBoost\boostc.pic16.exe MultiControl.c -t PIC16F876A Exit code was 1. Removing target: MultiControl.obj Done
  19. I was not recommending one. Just pointing out some of the things that you should look for when selecting a bootloader. Once you want to program a PIC from a device other than a PC, then the tiny bootloader is no good for you. But if you can get away from this requirement and you do not need any other features I mentioned then it will be fine. <{POST_SNAPBACK}> What bootloader do you use if I can ask? Regards /Jörgen
  20. It depends on your own rquirements. If you want a bootloader that you use when you have a PIC sitting next to the bootloader and you want to use a RS232 port and the only code you will load into the PIC is code you have developed yourself and you want to reprogram the entire PIC each time then the tiny bootloader works well. The tiny bootloader is very small - all the intelligence sits in the PC end. If on the otherhand you want to: 1. Bootload remote systems (100s or 1000s of km away) 2. support incremental bootloading (ability to change as little as a single byte) 3. Use other physical media such as SPI, I2C, USB, Parallel, Ethernet ... 4. Use code compiled by others that is not bootloader aware 5. Have multiple target systems on a bus 6. Need to be able to program cascaded PICs (downstream from a master PIC) 7. bootload over multiple interfaces (RS232, RS485, USB....) simultaneously 8. bootload over a system other than a PC Incremental bootloading enables you to patch an image, change a hardcoded parameter (such as serial number, baud rate, MAC address etc). If you require these types of capabilities, then you need a different class of bootloader. <{POST_SNAPBACK}> I will only download own code but it will be done from a computer or a other PIC alike device(programmable GSM). What bootloader do you recommend? Regards /Jörgen
  21. What bootloader is the best and how to use it in Boostc? What about tiny PIC bootloader any experience? Regards /Jörgen
  22. Hello Gerhard, I am thinking of useing tinybootloader do you have any info how to use it with BoostC? Regards /Jörgen
  23. Sorry... I write the wrong it should be likte below. But it was not that it was stupied me that was out of a array. Thanks any way Regards /Jörgen LimitOFF1Temp = eeprom_read(EE_LimitOFF1TempStart+i); //Gives wrong value j = EE_LimitOFF1TempStart + i; LimitOFF1Temp = eeprom_read(j); //Give corrct value.
  24. Why is the differens in the code below one gives the corrct value and the other not? Regards /Jörgen LimitOFF1Temp = eeprom_read(EE_LimitOFF1TempStart+i); //Gives wrong value j = EE_LimitOFF1Temp + i; LimitOFF1Temp = eeprom_read(j); //Give corrct value.
  25. Sounds like one Can you supply a small program that demonstrates the problem, it will make its easier for us to find the issue. Regards Dave <{POST_SNAPBACK}> Can I mail you the project becasue it look like it works when I use it in a small test project? Regards /Jörgen
×
×
  • Create New...