# jsalisbury

EstablishedMember

18

0 Neutral

• Rank
Newbrie
1. ## Differences 6.x To 7.00 And Souceboost To Microchip Compiler

Hi, What are the differences bewteen 6.x and 7.0 and what are the signficant differences to the free microchip compiler? Thanks
2. ## Current Required To Charge A Capacitor

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. ## Pointer Subtraction Problem

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. ## Strtoi And Pointers Problem

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. ## Serial Driver And Fast Clocks

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. ## 12f And Gpio Simulator

Hi, Could GPIO be avaliable in the LED block in the simulator for the 12F series? Thanks

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. ## Need Guru Help

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. ## Source Boost 6.80 And Mplab 7.6 Linker Issue

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. ## Problems With Serial Example

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. ## Problems With Serial Example

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. ## Source Boost 6.80 And Mplab 7.6 Linker Issue

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

14. ## How To Use Ide Terminal

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. ## Rs232 Pic16f627(a) And The Sample Progarmmes

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?
×