Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About azoto

  • Rank
  1. hvn, please provide more details about what you want to do. Do you need to convert from a string containing 1s and 0s to a decimal (char or short) value? Just to avoid any possible misunderstanding, the following assignements are identical to the compiler (i.e. a-b==0): char a; a=1111011b; b=123; But probably you need some code for the first possibility, right?
  2. I forgot to say that I wrote the code for my 16F877... It's used to select either the EEPROM or the FLASH memory.
  3. Hope you don't mind... It's a little bit messy, but it does the job: unsigned char EE_read(char addr); void EE_wait(void); void EE_write(char addr, char data); unsigned char EE_read(char addr){ eeadr=addr; //0-255 destination address clear_bit(eecon1,EEPGD); //EEPGD=0 -> EEPROM; EEPGD=1 -> FLASH set_bit(eecon1,RD); //start reading return eedata; } void EE_wait(void) { while(test_bit(eecon1,WR)); } void EE_write(char addr, char data){ EE_wait(); eeadr=addr; //0-255 destination address eedata=data; clear_bit(eecon1,EEPGD); //EEPGD=0 -> EEPROM; EEPGD=1 -> FLASH set_bit(eecon1,WREN); clear_bit(intcon, GIE);//disable interrupts asm { MOVLW 0x55 MOVWF _eecon2 MOVLW AAh MOVWF _eecon2 } set_bit(eecon1,WR); set_bit(intcon, GIE);//reenable interrupts clear_bit(eecon1,WREN); } After seeing the C2C code I guess that probably the asm lines can be deleted and two direct assignements could be used...
  4. Marco, why don't you post the C2C code? Prolly someone could port it to BoostC. cheers
  5. take a look at lcd_driver.h "C:\Program Files\SourceBoost\include" you should find something really cool.
  6. Thanks guys! I didn't use ExpressPCB, but I think you cannot automatically convert your schematic to a PCB, right? At the moment I'm giving Protel a try and it looks neat cheers
  7. Hi sdujolo, are you using TMR1L or tmr1l? The former is a const, the latter a register and I guess TMR1L == 14. Cheers
  8. Hi Drone, GO represents a constant and therefore you can't use while(GO==1) Try with volatile bit adc_go @ ADCON0 . GO; ... adc_go=1; while(adc_go); ... adcval = (adresh << 8) + adresl; Again ADRESL is a const and guess its value... yes it's 158! Hope this helps.
  9. I need to start drafting my schematics and would like to know what to go for. Thanks
  10. Ok, problem SOLVED! thanks for all the replies... If someone is interested in the piece of code that "calculates" frequency and duty cycle, just drop a line.
  11. I feel so noob!!! Ok thanks! Just another tip: does char mean signed char and short mean signed short?
  12. I'm trying to print 59999 on my LCD and it doesn't work... yes, I can print lower number (the highest working number I tried is 19999). I tried two functions to do this: t = c/10000; //thousands print_cypher(t); t2 = t*10000; c=c-t2; t = c/1000; //thousands print_cypher(t); t2 = t*1000; c=c-t2; t = c/100; //hundreds print_cypher(t); t2 = t*100; c=c-t2; t=c/10; //tens print_cypher(t); t=t*10; c=c-t; t=c; //ones print_cypher(t); And the following, that it's very similar to the one inside LCD_driver.h (but it comes from another example on the net) while(i) { i--; buf[i] = (unsigned char)(c % base); c-=buf[i]; c /= base; if(c == 0) break; } while(i<5) { print_cypher(buf[i]); i++; } Both behave in the same way: they print small numbers but cannot print 59999 for example (the result is a set of "strange" characters). Since both are using a / operator, I was wondering if there could be a sort of rounding happening only with big numbers. Thanks for any advice
  13. Hi guys I'm trying to create my own frequency counter, but I found a problem in determining the duty cycle. In particular I'm afraid that whenever I change from capture on rising edge to capture on falling edge, timer1 is reset. This is my code if( pir1 & (1<<CCP1IF) ) { if(rising) { newtimer=(ccpr1h<<8)|ccpr1l; freq=newtimer-newperiod; ccp1con=00000100b; //interrupt on falling edge } if(!rising) { newperiod=(ccpr1h<<8)|ccpr1l; period=newtimer-newperiod; ccp1con=00000101b; //interrupt on rising edge } clear_bit(pir1, CCP1IF ); //clear CCP1 interrupt bit } When I remove the second if (falling edge) everything goes smooth. Any idea or sample code? Thanks
  14. Hi Frans, please allow me only one question, I'm a newbie and want to learn... Why do you need the LVP to be enabled if you're using a bootloader? I thought the BL only needs the code not to be protected... Am I completely wrong? It's crystal clear! Thanks a lot for your explanation. I'll tie down RB3 with a 10K resistor to avoid any further issue. Kind regards
  15. ... same problem here (that damn datasheet is too long) But to me it was sufficient to set RB3 as a low output (no resistor, no connections). Is there any difference or advantage between the two solutions?
  • Create New...