Jump to content

Search the Community

Showing results for tags 'PIC16F610'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • PIC Embedded Programming
    • BoostC and Chameleon compilers programming
    • BoostC porting source code
    • BoostC++ compiler programming
    • BoostBasic compiler programming
    • Assembler programming PIC
    • Novo RTOS Programming
    • Hardware PIC
    • Enhancement Requests
    • Bug Reports

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hey guys I am working on an extremely simple project, but I am beating my head trying to get it to work the way I want. If you look down you will see that I call the delay_s function two times. I did this because on the final version of the software I will have to delay for a few minutes, therefore I will go over the 255 maximum for the delay functions (unless this has changed). What is happening is that my delay is twice what it should be. I have commented out the second delay function call and still with a single function call I am getting twice the time. I am sure there is something simple that I am overlooking but it is driving me nuts. //----------------INITIATE------------------- void initiate(void) { option_reg = 0x00; // bit 7=0 enable pullups // bit 6=0 don't care // bit 5=0 Fosc/4 = tmr0 clock // bit 4=0 don't care // bit 3=0 prescaler assigned to tmr0 // bits 2-0=000 prescale = 1:2 (won't use) cm1con0 &= 0x7F; //turn comparator cm2con0 &= 0x7F; //features off ansel = 0x00; //porta bits all set as digital I/O's wpua = 0x1B; //enable all pullups on porta ioca = 0x10; //interrupt on change enabled for porta bit 4 trisa = 0x3F; //bit 7-6 = unimplemented //bit 5 = spare input #2 //bit 4 = PushButton input (interrupt on change) //bit 3 = MCLR //bit 2 = MIN 2 input (seconds to run bit 2) //bit 1 = MIN 1 input (seconds to run bit 1) //bit 0 = MIN 0 input (seconds to run bit 0) trisc = 0x20; //bit 7-6 = unimplemented //bit 5 = spare input #1 //bit 4 = spare output #3 //bit 3 = spare output #2 //bit 2 = spare output #1 //bit 1 = active high output //bit 0 = active low output portc = 0x01; //outputs initially off (active high = 0, active low = 1) intcon |= 0x88; //turn on global & change on porta interrupts } //PIC16F610 #include <system.h> #include "initialization.h" #pragma CLOCK_FREQ 4000000; //*********************************************** //USE THIS CONFIGURATION FOR INTERNAL OSCILLATOR #pragma DATA 0x2007, 0xFC64 /* device configuration block ;bit 15-10 = 111111 -> unimplemented (read as '1') ;bit 9-8 = 00 -> BOR disabled ;bit 7 = 0 -> 4MHz internal clock ;bit 6 = 0 -> program memory code protect disabled ;bit 5 = 1 -> MCLR pin is MCLR function ;bit 4 = 0 -> PWRT enabled ;bit 3 = 0 -> WDT disabled ;bit 2-0 = 100 -> INTOSCIO oscillator ************************************************/ #define vac_on (portc |= 0x02) #define vac_on2 (portc &= 0xFE) #define vac_off (portc &= 0xFD) #define vac_off2 (portc |= 0x01) #define button_pressed ((porta|0xEF) == 0xEF) bit start_timer = 0; unsigned char rotary = 0, tick = 0, tock = 0; //------------INTERRUPT HANDLER-------------- //interrupt occurs when RA4 has changed state //when this interrupt occurs the micro is "woken" void interrupt(void) { intcon &= 0xFE; //clear interrupt flag rotary = porta; start_timer = 1; } //---------------------------------------------------------------------- void main() { initiate(); while(1) { if(start_timer == 1) { intcon &= 0x7F; //disable interrupts rotary &= 0x07; //only need bits 0-2 /* Rotary Input Run Time (minutes) 111 0 110 1 101 2 100 3 011 4 010 5 001 0 000 0 */ switch(rotary) { case 0: tick = 0; tock = 0; break; case 1: tick = 0; tock = 0; break; case 2: tick = 25;//150; tock = 25;//150; break; case 3: tick = 20;//120; tock = 20;//120; break; case 4: tick = 15;//90; tock = 15;//90; break; case 5: tick = 10;//60; tock = 10;//60; break; case 6: tick = 5;//30; tock = 5;//30; break; case 7: tick = 0; tock = 0; break; } if(tick > 0) { vac_on; vac_on2; delay_s(tick); //activate output for amount of time //determined by rotary switch inputs delay_s(tock); //delay_s function uses char (8-bits) //therefore it must be called twice //if time is greater than 255secs vac_off; vac_off2; } start_timer = 0; //reset flag intcon |= 0x88; //turn on global & change on porta interrupts sleep(); //go to sleep until interrupt on change occurs nop(); //when it awakens it will perform this before going to ISR } } }
×
×
  • Create New...