Jump to content

jsalisbury

EstablishedMember
  • Content Count

    18
  • Joined

  • Last visited

Community Reputation

0 Neutral

About jsalisbury

  • Rank
    Newbrie
  1. Hi, What are the differences bewteen 6.x and 7.0 and what are the signficant differences to the free microchip compiler? Thanks
  2. DANGER! Risk of DEATH The energy stored in that capacitor will cause death to anyone who touches it, are you sure you are up to the task. The chargeing current is only one of several concerns, how are you going to discharge it? 380 Joules is a lot of energy, more than in some defibulators!
  3. Hi,I am trying to subtract a pointer but I get the error invalide opperand and failed to generate expression at line 244 any idea? Thanks char get_credit (void) { char test_string[]="Your balance is £4.38."; //char *CUSD = "AT+CUSD=1,*#10#"; char *pnd_point; char *dec_point; int length; char cb [5]; //char pnd='£'; //char dec='.'; int credit_pnd; int credit_pence; //puts ("AT+CUSD=1,*#10#"); //gsm_gets (rx_array); strcpy (rx_array,test_string); pnd_point =strchr (rx_array,'£'); dec_point =strchr (rx_array,0x2E); length =(pnd_point - dec_point); // line 244 strncpy (cb,(pnd_point+1),(length)); credit_pnd = atoi (cb); strncpy (cb,(dec_point+1),2); credit_pence = atoi (cb); if (credit_pnd >5) { portb.0 = 1; portb.1 = 0; } else { portb.0 = 0; portb.1 = 1; } }
  4. Hi, I am trying to convert the string "Your balance is £4.35." to credit_pound =4 credit_pence = 35 I am trying to use the code below but at compile time I am getting the errors shown at the end, what am I doing wrong? Thanks #include <system.h> #include <stdio.h> #include <icd2.h> #include <string.h> #include "phone.h" #define FIFO_SIZE 128 char rx_array [FIFO_SIZE]; char tx_array [FIFO_SIZE]; char get_credit (void) { //char *CUSD = "AT+CUSD=1,*#10#"; char *pnd_point; char *dec_point; //char pnd='£'; //char dec='.'; int credit_pnd; int credit_pence; puts ("AT+CUSD=1,*#10#"); gsm_gets (rx_array); pnd_point =strchr (rx_array,'£'); // line 239 dec_point =strchr (rx_array,'.'); credit_pnd = strtoi((pnd_point+1),(dec_point-1),10); // line 241 credit_pence = strtoi((dec_point+1),(dec_point+3),10); // line 242 if (credit_pnd >5) { portb.0 = 1; portb.1 = 0; } else { portb.0 = 0; portb.1 = 1; } } E:\projects\phone_v2\phone.c(239): warning: conversion from 'signed char' to 'unsigned char', possible loss of data E:\projects\phone_v2\phone.c(241:14): error: unknown identifier 'strtoi' E:\projects\phone_v2\phone.c(241:14): error: failed to generate expression E:\projects\phone_v2\phone.c(241:14): error: invalid operand 'strtoi((pnd_point+1),(dec_point-1),10)' E:\projects\phone_v2\phone.c(241:12): error: failed to generate expression E:\projects\phone_v2\phone.c(242:16): error: unknown identifier 'strtoi' E:\projects\phone_v2\phone.c(242:16): error: failed to generate expression E:\projects\phone_v2\phone.c(242:16): error: invalid operand 'strtoi((dec_point+1),(dec_point+3),10)' E:\projects\phone_v2\phone.c(242:14): error: failed to generate expression E:\projects\phone_v2\phone.c(243:5): warning: local variable 'credit_pnd' may be used uninitialized
  5. Hi, I wish to use an 18.432 MHz clock and 9600 baud RS232. Could this be updated for the 18F2520 and other fast micros, to take advantage of the autobaud and other features. Thanks
  6. Hi, Could GPIO be avaliable in the LED block in the simulator for the 12F series? Thanks
  7. I am wanting to form a modem control string, I am getting ATD 01234567890; Where I wanted ATD 01234567890 this is the code puts("ATD "); for(counter = 0; counter < number_length ; counter++) putc(phone_number[counter]); where am I going wrong?
  8. Ok Go take your self down to a book store and buy a copy of Designing Imbeded systems with pic microcontrollers by Tim Wilmshurst... ISBN 0-7506-6755-9
  9. Check linker settings and associated .exe as it doesn't seem to be being invoked.Go through the MPLAB integration steps in the BoostC User Reference Manual. Regards Dave It is now sorted I reinstalled both MPLAB and SOURCEBOOST. You might want to check the integration script, MPLAB points to the old linker and there are a couple of other issues.
  10. Please explain again, I don't quite understand your problem. Regards Dave At the moment if I set my pc to 9600, 7 bit no parity and one stop bit (9600,7,n,1) I get a corrupted hello world, which is not even repeatable, hence the string above. BUT the getc putc is working correctly.... I would like both the hello world and the getc putc to work correctly at 9600,8,n,1 I hope this makes it a bit clearer? All sorted once I got my debugger working! it is an overflow issue if you are only runing at 4MHz, cured by useing the hardware uart...
  11. Please explain again, I don't quite understand your problem. Regards Dave At the moment if I set my pc to 9600, 7 bit no parity and one stop bit (9600,7,n,1) I get a corrupted hello world, which is not even repeatable, hence the string above. BUT the getc putc is working correctly.... I would like both the hello world and the getc putc to work correctly at 9600,8,n,1 I hope this makes it a bit clearer?
  12. I am trying to get mplab to build my project so I can make sensible use of my ICD2. When I try to build inside mplab 7.6 I get what is shown below, what would you suggest as starters? Executing: "C:\Program Files\SourceBoost\boostc.pic18.exe" serial_test.c -O1 -W1 -v -t 18F452 BoostC Optimizing C Compiler Version 6.80 (for PIC18 architecture) http://www.sourceboost.com Copyright© 2004-2007 Pavel Baranov Copyright© 2004-2007 David Hobday Licensed to James Salisbury under Single user Full License for 1 node(s) Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only serial_test.c Starting preprocessor: "C:\Program Files\SourceBoost\pp.exe" "C:\Program Files\SourceBoost\mplab\serial_test.c" -i "C:\Program Files\SourceBoost\include" -d _PIC18F452 -la -c2 -o serial_test.pp -v -d _BOOSTC -d _PIC18 <C:\Program Files\SourceBoost\include\icd2.h> @ 20: MESSAGE: "Including ICD2 declarations (icd2.h)" <C:\Program Files\SourceBoost\include\icd2.h> @ 1161: MESSAGE: "Warning: ICD2 Reserved ROM address range:0x7DC0-0x7FFF (use linker -rt option)" serial_test.c success success BUILD FAILED: Mon Aug 27 00:14:15 2007
  13. Hi, I am trying to get the source boost serial example to work. When I used 9600 7-n-1 the remote copy works fine but the hello world comes back as below when I push reset several times $1667;7:62$3647;7:62$1667;7:60$1667;7:62$1667;7:62$3467;7:62 Where am I going wrong? I would like it to be 9600, 8-n-1 and I would like to use the HW uart. thanks //////////////////////////////////////////////////////////////////////////// // 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-2007 Pavel Baranov // Copyright© 2004-2007 David Hobday // Initialially developed on the PIC18F452 //////////////////////////////////////////////////////////////////////////// #pragma CLOCK_FREQ 4000000 #include <system.h> //////////////////////////////////////////////////////////////////////////// // 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 0x0f8b #define TX_TRIS 0x0f94 #define TX_BIT 6 #define RX_PORT 0x0f82 #define RX_TRIS 0x0f94 #define RX_BIT 7 #define e_SPBRG 0x47 #define e_RCREG 0x48 #define e_TXREG 0x49 #define e_TXSTA 0x4A #define e_RCSTA 0x4B #define e_TXIF_PIR 0x4C #define e_RCIF_PIR 0x4C #define e_TXIF_BIT 4 #define e_RCIF_BIT 5 #define MODE (USART_reset_wdt) //////////////////////////////////////////////////////////////////////////// // 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 86 // 115200 baud at 40MHz #define bit_time 104 // 9600 baud at 4MHz //////////////////////////////////////////////////////////////////////////// // 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 uart_init(1,25); // set high speed divisor mode and divisor value puts("Hello, world"); while (1) { if (kbhit()) { putc(getc()); } } }
  14. I would like to be able to see the output of the attached on the IDE terminal. It is set to 9600 and no flow control, where am I going wrong? #include <system.h> // target PIC16F628 //Configuration Bits #pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _MCLRE_OFF & _HS_OSC #define spBAUD 9600 #define FOSC 20000000L #define fSPBCLK (FOSC) /* UART Baud rate generator clock (high speed) */ //#define fSPBCLK (FOSC / 4) /* UART Baud rate generator clock (low speed) */ #define SPBRG_VAL (fSPBCLK / (spBAUD * 16L)) - 1L //////////////////////////////////////////////////////////////////////////// // The following three sections should be copied to the user's program: // USART software implementation template arguments and variables // USART hardwareware implementation template arguments //////////////////////////////////////////////////////////////////////////// // // **** START OF DEFAULTS USED FOR SOFTWARE USART EMULATION **** // //////////////////////////////////////////////////////////////////////////// // 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. // // // PIC16F628 defaults for hardware USART support #define TX_PORT 0x06 #define TX_TRIS 0x86 #define TX_BIT 2 #define RX_PORT 0x06 #define RX_TRIS 0x86 #define RX_BIT 1 #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 #define e_TXIF_BIT 4 #define e_RCIF_BIT 5 #define MODE (USART_reset_wdt | USART_HW) // 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@e_SPBRG; // define location for the emulated SSPCON1 //unsigned short sw_RCREG@e_RCREG; // define location for the emulated SSPCON2 //unsigned short sw_TXREG@e_TXREG; // define location for the emulated SSPSTAT //unsigned short sw_TXSTA@e_TXSTA; // define location for the emulated SSPBUF //unsigned short sw_RCSTA@e_RCSTA; // define location for the emulated SSPADD //unsigned short sw_TXIF_PIR@e_TXIF_PIR;// define location for the emulated TXIF_PIR1 //unsigned short sw_RCIF_PIR@e_RCIF_PIR;// define location for the emulated RCIF_PIR1 //////////////////////////////////////////////////////////////////////////// // 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 20MHz the minimum standard baud rate is 300 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 //////////////////////////////////////////////////////////////////////////// #if (spBAUD==115200) #define bit_time 43 // 115200 baud at 20MHz #endif #if (spBAUD==9600) #define bit_time 521 // 9600 baud at 20MHz #endif #if (spBAUD==600) #define bit_time 8333 // 600 baud at 20MHz #endif // // **** END OF DEFAULTS USED FOR SOFTWARE USART EMULATION **** ///////////////////////////////////////////////////////////// // This test code works with the PIC-PG4-628 demo board // from Olimex (http://www.olimex.com/dev/index.html) ///////////////////////////////////////////////////////////// //20 MHz quartz #pragma CLOCK_FREQ 20000000 //Serial functions #include <rs232_driver.h> //Main entry point void main() { //Hardware Initialization cmcon = 7; vrcon = 0; trisa = 0; trisb = 0; porta = 0; portb = 0; // 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 // rs232_driver.h - this file also contains the address mapping for // RAM required to support the software emulated USART uart_init(1,SPBRG_VAL); // set high speed divisor mode and divisor value //Output test string into serial port putc( 'T' ); putc( 'e' ); putc( 's' ); putc( 't' ); putc( '\r' ); putc( '\n' ); //Flash PortA.2 LED in endless loop while( 1 ) { porta.2 = 1; // turn off LED delay_ms( 250 ); porta.2 = 0; // turn on LED delay_ms( 250 ); } }
  15. Unless you really are using Low Voltage Programming (very few hobbyists are) you want LVP_OFF Hi, Would like to use this with the teminal within the debuger, how do I see the output in the terminal window?
×
×
  • Create New...