Jump to content

sdujolo

EstablishedMember
  • Content Count

    96
  • Joined

  • Last visited

Everything posted by sdujolo

  1. I have a function that returning struct below. The vaiable that is first in the struct is not correct. When I but the dummy variable that not is used it´s okay. Is it a bugg? Thanks typedef struct temp_data { char chr_temp; //Value is always 0 char negative; char chr_decimal; int temp; int decimal; } oo_temp; typedef struct temp_data { char dummy; //just a dummy variable that is not used char chr_temp; //Working is have the dummy variable before char negative; char chr_decimal; int temp; int decimal; } oo_temp;
  2. Hello, Is it not possible to have bit or bool in a typedef struct? I get this error. Regards /Jörgen oo_test.c oo.h(40:2): error: struct/union can't have 'bit' data members C:\Program\SourceBoost\boostc.pic16.exe oo_test.c -t PIC16F876A Exit code was -1073741819. Removing target: oo_test.obj Done
  3. Hi, I get this error in the IDE when doing some calulation. "Can´t locate source line for the current instruction" Here is the code... x *= 10; //Gives the error x += ((int)rx_queue -48); //OK It´s only in the IDE it´s works on the real chip.
  4. Hello, I have posted some of this before but why can´t you have a UART simulator as a plugin and also a EEPROM editor. Look at http://www.oshonsoft.com/ his simulator is great and have this function and more. And why not release plugins as opensource so all can help makeing them better and it will also be easy to make new if people have examples to look at. I also find that the oo lib is is only working if you have a crystal at 10MHz becasue it use nop instruction in the code. Regards /Jörgen
  5. I have tryed diffrent ports and all things I can think of any ides? Regards /Jörgen
  6. Hello I can´t get correct readings from DS18S20. This is the result I get. Temperature conversion timed outTemperature: FFFF -- 255.5 degrees C. here is some part of the code. I am using a PIC16F648A. #include <system.h> #include "serial.h" #include "oo.h" #define OO_PORT PORTB #define OO_TRIS TRISB #define OO_PIN 6 volatile bit oo_bus @ OO_PORT . OO_PIN; volatile bit oo_bus_tris @ OO_TRIS . OO_PIN; #pragma DATA 0x2007, 0x3F50 #pragma CLOCK_FREQ 4000000 .. ... trisa = 11000000b; // 1=input trisb = 11000010b; // 1=input vrcon = 0x00; // turn off voltage reference module cmcon = 0x07; // turn off comparator set_bit(pie1, RCIE); //enable USART receive interrupt bit intcon = 11000000b; //set interrupts on set_bit(intcon, PEIE); set_bit(intcon, GIE); ... .... while( 1 ) { // Allow wakeup delay_ms(100); // Reset the one wire bus oo_busreset(); // Start the temparature conversion (non-blocking function) oo_start_conversion(); // Wait for completion, you could do other stuff here // But make sure that this function returns zero before // reading the scratchpad if (oo_wait_for_completion() == 1){ serial_printf("Temperature conversion timed out"); } // Read the scratchpad if (oo_read_scratchpad()){ serial_printf("OO read scratchpad failed"); while(1); } // And extract the temperature information short temp = oo_get_data(); // The temperature is serial_printf("Temperature: "); serial_print_hex(temp); serial_printf(" -- "); // And for positive temps you can simply convert this to char tmp_work = (char)(temp >> 1); serial_print_dec(tmp_work); if (temp & 0x0001){ serial_printf(".5"); } else { serial_printf(".0"); } serial_printf(" degrees C.\r\n"); // A more accurate conversion is described in the DS1820 datasheet. delay_s(1);
  7. I guess you mean a simualted RS232 terminal, so you can communicate with the virtual pic running under the simulator. If this is what you mean, I've been thinking about this for a long time. I would like to write such a plugin. I couldn't find this here - http://www.oshonsoft.com, so maybe you mean something else? Regards Dave <{POST_SNAPBACK}> Yes so you can communicate with the virtual pic running under the simulator. Maybe also have plugin communicate whit a fysical serial port so you can run a external app, hardware or what ever communicate with the simulator. It should be on this website http://www.oshonsoft.com/pic.html you can download a demo. Sorry for my english hope you understand me. Regards /Jörgen
  8. Why not have a Hardware UART plugin similar to "PIC Simulator IDE" (http://www.oshonsoft.com). /Jörgen
  9. Is there any code example of the new one wire interface library?
  10. I am using BoostC and running at 10MHz Here is the code. //////////////////////////////////////////////////////////////////////////// // Serial Communications Test Program // // Exercises the serial driver code in <rs232_driver.h> by reading and // writing to the serial port //////////////////////////////////////////////////////////////////////////// // Author(s): Andrew Smallridge // Date 17 November 2004 // // Copyright © 2004-2006 Andrew Smallridge // Copyright © 2004-2006 Pavel Baranov // Copyright © 2004-2006 David Hobday // Initialially developed on the PIC18F452 //////////////////////////////////////////////////////////////////////////// //Target PIC16F628 configuration word #pragma DATA _CONFIG, _PWRTE_OFF & _WDT_OFF & _HS_OSC & _CP_OFF //Set clock frequency #pragma CLOCK_FREQ 10000000 //////////////////////////////////////////////////////////////////////////// // The following three sections have been copied from the serial_driver.h file // USART software implementation template arguments and variables // USART hardwareware implementation template arguments //////////////////////////////////////////////////////////////////////////// // // **** START OF DEFAULTS USED FOR SOFTWARE USART EMULATION **** // // RAM used by the software USART driver to emulate the equivalent serial hardware registers // Note this section is really just reserving the space. The defines in the subsequent section // overlay these RAM locations /*unsigned short sw_SPBRG@0x47; // define location for the emulated SSPCON1 unsigned short sw_RCREG@0x48; // define location for the emulated SSPCON2 unsigned short sw_TXREG@0x49; // define location for the emulated SSPSTAT unsigned short sw_TXSTA@0x4A; // define location for the emulated SSPBUF unsigned short sw_RCSTA@0x4B; // define location for the emulated SSPADD unsigned short sw_TXIF_PIR@0x4C;// define location for the emulated TXIF_PIR1 unsigned short sw_RCIF_PIR@0x4C;// define location for the emulated RCIF_PIR1 */ //////////////////////////////////////////////////////////////////////////// // USART software implementation template argument values //////////////////////////////////////////////////////////////////////////// // variables cannot be passed as template arguments. The following constants map to // the PIC registers and software emulated USART RAM locations. These constants are // then used by the templated functions. When changing the address of an emulated // register the corresponding constant mapping must also be changed. // PIC18F defaults for software emulated USART support #define TX_PORT 0x06 // PORT B #define TX_TRIS 0x86 // TRISB #define TX_BIT 2 #define RX_PORT 0x06 // PORTB #define RX_TRIS 0x86 // TRISB #define RX_BIT 1 #define MODE (USART_HW) #define e_TXIF_BIT 4 #define e_RCIF_BIT 5 #define e_SPBRG 0x99 #define e_RCREG 0x1a #define e_TXREG 0x19 #define e_TXSTA 0x98 #define e_RCSTA 0x18 #define e_TXIF_PIR 0x0c #define e_RCIF_PIR 0x0c //////////////////////////////////////////////////////////////////////////// // bit_time is used by the software emulated USART and is the number of CPU // instruction cycles per bit. // // bit_time = FOSC / 4 / BAUDRATE // The maximum value of bit_time currently limited to approximately 24000 // and is determined by the maximum word size supported by the compiler. // this will change when 32 bit variables are supported. // At FOSC of 40MHz the minimum standard baud rate is 600 baud. // When using the software emulated USART functions ensure that the baud rate // can be realistically supported by the FOSC used. bit_time values below // 36 will likely lead to unreliable comms. // // The software UART takes 8 instruction cycles in a bit time loop. Therefore // the driver software divides the bit_time value by 8. If experimenting with // different values for bit_time use increments of 8 to guarentee a different // bit time is selected //////////////////////////////////////////////////////////////////////////// #define bit_time 130 // 19200 baud at 10MHz //#define bit_time 86 // 115200 baud at 40MHz //#define bit_time 1041 // 9600 baud at 40MHz //////////////////////////////////////////////////////////////////////////// // Serial Control Flag Bits used for the MODE parameter // // DO NOT REMOVE THE COMMENTS FROM THE FOLLOWING FLAGS // These flags are defined in serial_driver.h and are include here for information // only. These flags are used in the MODE parameter. // // The USART_invert flag is used to signal the software UART that the serial // input and output signals are inverted from normal RS232 communications. // Hardware implementations that use standard RS232 transievers // such as MS1488/MC1489 or MAX232 line drivers / receivers do NOT require this flag. // // The flags USART_HW and the USART_invert are mutually exclusive. // // Sample use: #define MODE (USART_reset_wdt | USART_HW) // //////////////////////////////////////////////////////////////////////////// // define USART Mode bits //#define USART_HW 0x01 // specifies use the HW USART in the PIC //#define USART_invert 0x02 // invert the tx and rx bits //#define USART_reset_wdt 0x04 // reset the WDT while waiting for a character in getc() // **** END OF DEFAULTS USED FOR SOFTWARE USART EMULATION **** #include <rs232_driver.h> void main() { // for the hardware UART the paramter passed is the divisor // the hardware usart enables dynamic reconfiguration of the baud rate // the software emulated USART baud rate is defined by constants in // serial_driver.h - this file alos contains the address mapping for // RAM required to support the software emulated USART cmcon = 00000111b; //comparators off uart_init(1, 129); // set high speed divisor mode and divisor value puts("Hello, world"); while (1) { if (kbhit()) { putc(getc()); } } }
  11. How do I configure the serial_test example to work has hardware serial link whit PIC16F648A? I can´t get it work
  12. I don´t know what is the problem but I get it working. I started a new project and copy the same code and then it was working again.
  13. That´s the wierd thing first it worked for me to but after some time it stoped working. I have the pin connected right the LCD plugin works if I take the timer1 code out. I installed the 6.13 patch but in the about box it say 6.12 did you just forgot to change it to 6.13? BR /Jörgen
  14. Sorry about that the target is PIC16F88. BR /Jörgen
  15. Here is the code I am using when adding timer1 the simulator/debuger stop to work. //////////////////////////////////////////////////////////////////////////// // Test code for LCD library //////////////////////////////////////////////////////////////////////////// // Author(s): David Hobday, Pavel Baranov // Date 15 November 2004 // // Copyright © 2004-2005 Pavel Baranov // Copyright © 2004-2005 David Hobday //////////////////////////////////////////////////////////////////////////// // // Originally Designed and tested for 16F84A // Also works (and tested) with PICDEM 2 PLUS board using PIC18F452 and PIC16F877 // with clock freq 4MHz. // // This code works under SourceBoost debugger/simulator with the LCD Plugin. // //////////////////////////////////////////////////////////////////////////// // Revisions // ========= // // V1.00 - ??? // =========== // The begining, before this revision history was started! // // V1.10 25/03/2005 David Hobday // ============================= // 1) Added some new formated output tests. // 2) Corrected some functions that use template functions without arguments // - compiler allowed this once, but now is fixed. // //////////////////////////////////////////////////////////////////////////// #include <system.h> //#include <icd2.h> // only required if using ICD2 //////////////////////////////////////////////////////////////////////////// // LCD template arguments - defines how the LCD is connected to the PIC //////////////////////////////////////////////////////////////////////////// // These must be define before template header file is included // Remember when using LCD in 4 bit mode you must connect to the LCDs DB4-DB7 pin // // Using this code under SourceBoost simulator (for PIC16F877), configure the LCD // plugin as follows: // RS to RA3 // R/W to RA2 // E to RA1 // DB0 to None // DB1 to None // DB2 to None // DB3 to None // DB4 to RD0 // DB5 to RD1 // DB6 to RD2 // DB7 to RD3 // // These setting are correct for PICDEM2 PLUS board with PIC16F877 or PIC18F452 target! #define LCD_ARGS 2, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \ 1, /* Use busy signal: 1 = use busy, 0 = use time delays */\ PORTA, TRISA, /* Data port and data port tris register */ \ PORTB, TRISB, /* Control port and control port tris register */ \ 3, /* Bit number of control port is connected to RS */ \ 1, /* Bit number of control port is connected to RW */ \ 0 /* Bit number of control port is connected to Enable */ #include <lcd_driver.h> // include the LCD template code // Note: If using this code on a device with analog I/O pins (eg PIC16F877), // remember to turn off the analog functionality on the pins being used before // calling the lcd_setup() function, otherwise you will find that things don't // work as the port will partly in analog mode!! //////////////////////////////////////////////////////////////////////////// #ifdef _PIC16 #pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC #else #pragma DATA _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H #pragma DATA _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_OFF_2L #pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H #pragma DATA _CONFIG3H, _CCP2MX_ON_3H #pragma DATA _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L #pragma DATA _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L #pragma DATA _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H #pragma DATA _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L #pragma DATA _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H #pragma DATA _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L #pragma DATA _CONFIG7H, _EBTRB_OFF_7H #endif #pragma CLOCK_FREQ 8000000 // Sim doesn't run as fast as actual device, so we change the delays so we don't // have to wait too long for the tests to complete #define RUN_UNDER_SIM // sim doesn't run in real time, so we will use shorter delays under sim. #ifdef RUN_UNDER_SIM #define DELAY delay_ms( 36 ) #define DELAY_SHORT delay_ms( 12 ) #else #define DELAY delay_s( 2 ) #define DELAY_SHORT delay_ms( 100 ) #endif void interrupt(void) { //Handle port change interrupt if( intcon & (1<<RBIF) ) { clear_bit( intcon, RBIF ); } //Handle timer0 interrupt if( intcon & (1<<TMR0IF) ) { clear_bit( intcon, TMR0IF ); //clear timer 0 interrupt bit } //Handle timer1 interrupt if( pir1 & (1<<TMR1IF) ) { clear_bit( pir1, TMR1IF ); //clear timer 1 interrupt bit } //Handle timer2 interrupt if( pir1 & (1<<TMR2IF) ) { clear_bit( pir1, TMR2IF ); //clear timer 2 interrupt bit } } void main() { //*********************// // configure I/O ports // //*********************// portb = 00000000b; trisb = 11010100b; //0 = Output, 1 = Input osccon = 01110000b; //internal oscillator @ 8MHz cmcon = 00000111b; //comparators off adcon1 = 00000000b; // - turn PortA inputs that we are using into digital mode intcon = 11001000b; // Set global interupt, PEIE: Peripheral Interrupt Enable bit(needed for RX), RBIE: RB Port Change Interrupt Enable bit //*****************// // configure USART // //*****************// spbrg = 51; //9600 baud @ 8MHz txsta=00100100b; //full duplex asynchronous rcsta=10010000b; //full duplex asynchronous set_bit( pir1, RCIE ); //RCIE: AUSART Receive Interrupt Enable bit set_bit( pir1, PEIE ); //enable peripheral interrupts (needed for RX) //Set timer 1 prescaler rate clear_bit( t1con, T1CKPS1 ); //prescaler rate 1:1 clear_bit( t1con, T1CKPS0 ); //Set timer 1 mode clear_bit( t1con, TMR1CS ); //Internal clock (FOSC/4) set_bit( t1con, TMR1ON ); //enable timer 1 lcd_setup(); while( 1 ) { lprintf( "TMR1l:%d", tmr1l ); DELAY; // generate formated output a check its as expected //lcd_gotoxy( 0, 1 ); //lprintf( "TMR1H:%d", tmr1h ); //DELAY; lcd_clear(); //LcdReadBack( buff1, sizeof( buff1 ) ); } } void LcdReadBack( char* txt, char cnt ) { lcd_datamode(); char i; cnt--; for( i = 0; i != cnt; i++ ) { lcd_waitfornotbusy(); txt[ i ] = lcd_read(); } txt[ cnt ] = 0; // null terminate string } char StrEqu( const char* str1, const char* str2 ) { char i = 0, c1, c2; while( 1 ) { c1 = str1[ i ]; c2 = str2[ i ]; if( c1 != c2 ) return false; if( c1 == 0 ) break; i++; } return true; } void BadRes() { lprintf( "\nbad format read" ); while( 1 ); // wait forever }
  16. Hi had the same problem when I start to play wiht timer0 first it was working than it stopped working and after that I could never get the degbugger working again. I think it was the same why whit timer1 it first worked. Can I send you the code or something? Br /Jörgen
  17. Hi when I add this line in the code the debugger stops to work. I can still use F11 but its not possible to go in run mode. Any ides? //Set timer 1 mode clear_bit( t1con, TMR1CS ); //Internal clock (FOSC/4) set_bit( t1con, TMR1ON ); //enable timer 1
  18. Hello if I upgrade to BoostC will I also get my plugin upgraded? /Jörgen
  19. I try to read the value of TMR1L in to a variable but the result in the watch window show 14 all the time. The TMR1L in Registers window show the right value. Why can´t I read it in my program?
  20. Hello I have tryed to configure Logic Analyzer plugin and find it very hard and takes alot of time. Would it not be better if you can make the .sti files by type in values for example low20us, high15ms, low5ms ...... Or you can import from a text file. Maybe it is easy and I do something wrong? Best regards /Jörgen
×
×
  • Create New...