Jump to content

anks

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About anks

  • Rank
    Newbrie
  1. Hi thanks for the reply. I eventually worked out that it was not including the fuction that was not used to save space. Also the delay warning can be removed by comenting out the delay_us(1) in the rs232 driver. I think this is because a delay routine is not generated for a delay so small when using a 4mhz clock. Maybe is could be sorted by just adding a nop. Anyway it seems to function fine. Thanks again
  2. Hi im new to the board and Ive got a question that im sure is just a simple mistake made by me. Ive only been programing in boostc for a few days and its my first go at using pic's. So far im happy with my progress and I think boostc is excellent. My problem is that the compiler is giving me a warning regarding delays and im not sure whats its getting at about the gets function. Here is the warning. Caution: argument of 'delay_us' calls must have a value of 1 or more Caution: Delay inaccurrate: 'delay_us', Delay overhead:0.01ms, Unit delay:0.001ms, Delay resolution:4 units Warning unreferenced functions removed: gets in: D:\Program Files\SourceBoost\include\rs232_driver.h SignedIntOut in: D:\Documents and Settings\Admin\Desktop\Viv controler\12f675\12f675serial.c //////////////////////////// // Device: PIC12F675 // // Osc: 4MHz // // Test serial and adc // /////////////////////////// #include <system.h> // Set the device configuration bits #pragma DATA _CONFIG, _CPD_OFF & _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _MCLRE_OFF & _INTRC_OSC_NOCLKOUT // Tell the compiler the device clock frequency to get the correct delays generated #pragma CLOCK_FREQ 4000000 // 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 // Sample PIC16F675 defaults for software emulated USART support #define TX_PORT 0x05 // set to gpio reg address < #define TX_TRIS 0x85 // set to trisio reg address | TX set to pin3 #define TX_BIT 4 // set to gp4 -> pin3 < #define RX_PORT 0x05 // set to gpio reg address < #define RX_TRIS 0x85 // set to trisio reg | RX set to pin4 #define RX_BIT 3 // set to gp3 -> pin4 < #define e_SPBRG 0x99 #define e_RCREG 0x1a #define e_TXREG 0x019 #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) #define bit_time 104 // Include rs232 driver after setting defaults #include "rs232_driver.h" ////////////////////////////////////////////////////////////// // Output signed integer to terminal // // // ////////////////////////////////////////////////////////////// void Int_Out(int out) { char c; if (out < 0) { putc('-'); out = -out; } if (out > 10000) { c = out / 10000; putc('0'+c); out -= c * 10000; } if (out > 1000) { c = out / 1000; putc('0'+c); out -= c * 1000; } if (out > 100) { c = out / 100; putc('0'+c); out -= c * 100; } if (out > 10) { c = out / 10; putc('0'+c); out -= c * 10; } c = out; putc('0'+c); } // start main void main() { // Comparator module off cmcon=0x07; // ADC module on ansel=00010001b; // AN1 pin7 as analog input and fosc/8 adcon0=01000001b;// turn a/d on ADON // GPIO TRISTATE config trisio=00001000b;// all outputs except gp3->pin4 // set outputs to 0 gpio = 0x00; // Initialize serial uart uart_init(1,25); // Test serial puts("serial test"); delay_ms(250); // endless loop while(1) { // var to store ADC result int adc = 0; // Set adcon0 bit1(GO) as 1 to start a/d reading adcon0.1 = 1; // adcon0 bit1 will be 1 until reading is complete while(adcon0.1 == 1) { } // store result in adc adc = adresh; // print out adc result to terminal Int_Out(adc); if(adc <= 150) { gpio.5=0; } else { gpio.5=1; } } } // End main() any help much appreciated
×
×
  • Create New...