Jump to content

TomF

EstablishedMember
  • Content Count

    111
  • Joined

  • Last visited

Everything posted by TomF

  1. An example of handling interrupts with C++ compiler would be very useful, just searched the C++ manual PDF and found nothing. Im thinking of porting a BoostC program to BoostC++ and would need some examples of how to impliment interrupts.....
  2. +1 Ive been asking for this for a while! I use 12F devices all the time and im desprate for a simulator!
  3. Ahh yeah, a typo! I must of read that section of code a million times to try to find out why the inputs always read as zero! Gerr.. Thanks for the help.
  4. They are shared function in the device, im not using the other functionality as yet, and as far as i can tell from the data sheet, ive shut them off: cmcon1 = 0x07; // Disable comparators. ansel = 0x00; // Disable analog. I think thats all thats required??? I cant use the simulator to try this out, becuase i cannot attach a LED or a switch to port GPIO, only Port A, B .. etc.. which is a little anoying - the sim really does help in most other cases...
  5. Hi, I can read all ports, except GP0 and GP1. Im using the 12F683, and here is my code: The generated ASM is correct for reading the GP0 and GP5, so i guess there is somthing else im missing. Ive tied GP0 to 5V with a wire, but it always reads as zero. void main(void) { // Configure port. gpio = 0x00; cmcon1 = 0x07; // Disable comparators. ansel = 0x00; // Disable analog inputs, all inputs are digital. trisio = 0b11111011; wpu = 0x00; // Set weak pullups to all off. // Set interrupt on change pins. ioc = 0x00; delay_ms(250); // Allow power lines to stablise. for(;;) { // if( (gpio & (0x1 << 0)) == 0 ) // GP0 // if( (gpio & (0x1 << 1)) == 0 ) // GP1 if( (gpio & (0x1 << 5)) == 0 ) // GP5 { set_bit(gpio, 2); // turn on GP2 } else { clear_bit(gpio, 2); // turn off GP2 } } }
  6. Hi, Attempting to check for a bit in GPIO being set: if( gpio & (1 << 5) == (1 << 5) ) { set_bit(gpio, PIN_TRIAC); // bit is set } else { clear_bit(gpio, PIN_TRIAC); // bit is clear } if( gpio & (1 << 5) == (1<<5) ) 002E 1C05 BTFSS gbl_gpio,0 002F 2832 GOTO label268439188 0032 label268439188 { set_bit(gpio, PIN_TRIAC); 0030 1505 BSF gbl_gpio,2 } else 0031 282E GOTO label268439185 { clear_bit(gpio, PIN_TRIAC); 0032 1105 BCF gbl_gpio,2 } This does not work, the code below does work as expected: if( (gpio & (1 << 5)) == (1<<5) ) { set_bit(gpio, 1);// bit is set } else { clear_bit(gpio, 1);// bit is clear } if( (gpio & (1 << 5)) == (1<<5) ) 002E 3020 MOVLW 0x20 002F 0505 ANDWF gbl_gpio, W 0030 3A20 XORLW 0x20 0031 1D03 BTFSS STATUS,Z 0032 2835 GOTO label268439188 0035 label268439188 { set_bit(gpio, PIN_TRIAC); 0033 1505 BSF gbl_gpio,2 } else 0034 282E GOTO label268439185 { clear_bit(gpio, PIN_TRIAC); 0035 1105 BCF gbl_gpio,2 } Is this a bug? Im using 12F683, and BoostC 6.81 - Everything on the left of the == operator should be evaluated as a whole, so the resultant should be the same in both cases, which by looking at the .casm files (when added to the project, this files gets placed in the source dir rather than the output dir, another bug?) the generated ASM is different??
  7. Hi, What port do i assign buttons to for a device that only has a GPIO port? The button sim plugin has port A -> L, but no port GPIO. Tom
  8. Any chance someone who is good with the simulator could confirm this? Im not too good with the sim as yet and will probably make a mistake!
  9. Hi, Reading the datasheet (PIC16F876), it appears the PWM controllers both use the same timer, timer 2. Does this mean i cannot have 2 different PWM outputs at the same time? I need 2 PWM outputs, at the same frequency, but with different duty cycles.
×
×
  • Create New...