Jump to content

ajbeavan

EstablishedMember
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ajbeavan

  • Rank
    Newbrie

Profile Information

  • Gender
    Male
  • Location
    Pembroke, Wales
  • Interests
    Climbing, Running
  1. Hello I am struggling to get MPLABX v1.80 to compile and link my code, I get the following messages Error: Failed to open:../Program/ Error: Failed to open:Files/SourceBoost/Lib/libc.pic16.lib or C:\Program Files\SourceBoost\lib/Files/SourceBoost/Lib/libc.pic16.lib I do not really use MPLABX I prefer the Sourceboost IDE, but I am using the Pickit3 debugger to see whats actually on the chip and get realistic timings. To get around the problem I have used the 'cof' file produced by sourceboost to build a new project in MPLABX. It seems to work!!!!! I can step through the code and set breakpoints, though I cant make any sense of the timings for tmr0 and tmr1. I am using the timers to generate a PWM signal and setting them using the following code: volatile uWORD TMR1 @ 0x000E; //combine adj reg TMR1L & TMR1H #define STMR0 83 #define STMR1 536 ; ; //main program ; ; //set starting values for timers tmr0 = STMR0; TMR1 = STMR1; but they do not seem to be set when I step through and look at the register. Any suggestions.... Thanks adam
  2. sorry but I don't see this release candidate on the link given
  3. Hello I am using the ECCP module of a pic16f690 which is connected to a 555 timer generating a continuous train of pulses that i can adjust the period of using a POT. I am able to easily get the pulse width and period, but struggling to calculate the duty cycle. Presumable I will need to use Float point maths to get the duty cycle or can anyone offer some suggestions. adam
  4. Hello, Can anyone tell me if there is a way to disable interrupts within a block of code so that a calculation can be done, without the possibility of the interrupt being actioned. eg using the XC8 compiler, could write.... di() digit=period/4096 ei() adam
  5. Thanks...... well I certainly learnt a lot, though I can't say that being a LCD expert was ever high on my ambition list. But I am glad I didnt take a hammer to the whole!!!! adam
  6. Hi Dave Finally managed to sort the problem out, after spending so much time thinking about initialisation and 4-bit data mode, I forgot to check if the device had been wired the correct way..... I had everything back to front, so now after 2 weeks and writing my own LCD routines, it was simply a case of wiring. Feel like a real idiot. Sorry to waste your time adam
  7. Sorry, I added this line deliberately to hang the code, so that I could monitor the LED states on each of the DB ports at the point the BF flag was set....
  8. Hello I would be grateful for some help, before I go completely mad!!!! been working on this for 2 weeks. Have setup a simple circuit to write some output to an LCD which is controlled by a pic16F690. Everything works fine in the simulation. I have built the circuit, and now my problems start..... I have checked the wring and placed LED's on each of the control and data ports to see what is happening. I have managed to isolate the problem down to the LCD not resetting the BF flag after I have done the System reset and set the 4-bit function mode. The controller is a cheap JHd162A which is compatible with the HD44780, I have read the data sheet and really relaxed the timing, but no success. Please help, before a take a hammer to the whole lot, Have attached the LCD driver routine #include <system.h> #include <stdlib.h> #include "LCD_4BitHeader.h" VOID lcd_initial(){ /***************************************** Intialisation Of the LCD ******************************************/ trisc=trisb=OUTPUT; //set all data pins as output portb=portc=0; //clear the ports //configure portb to recieve code portb=WRITE_CODE; //Initial reset and delay sequence,not worried //about nibbles so send as a whole byte delay_ms(500); writeNIBBLE(0x30); //LCD System Reset delay_ms(200); writeNIBBLE(0x30); delay_ms(200); writeNIBBLE(0x30); delay_ms(200); writeNIBBLE(0x20); //Set 4-bit function mode delay_ms(200); writeToLCD(0x2C); delay_ms(200); writeToLCD(0x01); delay_ms(200); writeToLCD(0x06); delay_ms(200); writeToLCD(0x08); delay_ms(200); writeToLCD(0x0F); delay_ms(200); portb=WRITE_DATA; //write the letter 'Z' writeToLCD(0x5A); } VOID writeToLCD(UCHAR data){ /***************************************** Running in 4-bit mode so need to write the High and Low nibbles to the LCD. ******************************************/ writeNIBBLE(data & 0xF0); //mask the lower nibble writeNIBBLE(data << 4); //mask upper nibble waitBFLAG(); //check BF, still processing } VOID writeNIBBLE(UCHAR d){ /***************************************** Write the data onto portC and toggle the enable pin. ******************************************/ portc=d; //toggle the enable pin portb |= ENABLE_PIN; asm nop //pulse delay for enable portb &= ~ENABLE_PIN; } VOID waitBFLAG(){ /****************************************** Read portC and check the status of the BF flag on DB7 *******************************************/ UCHAR Hnibble=0x00,Lnibble=0x00; UCHAR tempb=0x00,tempc=0x00,count=0x00; UCHAR BFLAG=0x00; //assume BFlag is set at start tempb=portb; //store the current state of ports tempc=portc; trisc=INPUT; portb=READ_CODE; do {//check the status of busy flag //Read the High Nibble portb |= ENABLE_PIN; //Toggle Enable Pin asm nop Hnibble=portc & 0xF0; portb &= ~ENABLE_PIN; //Read the Low Nibble portb |= ENABLE_PIN; //Toggle Enable Pin asm nop Lnibble=(portc & 0xF0)>>4; portb &= ~ENABLE_PIN; //Combine nibbles to form busy status BFLAG=Hnibble+Lnibble; //Check to see if BF is timming out if(count++ == 0xFF){ trisa=OUTPUT; BFLAG=0x00; trisc=OUTPUT; //what sequence is failing portc=tempc; set_bit(porta,2); while(1) ; } } while(BFLAG & 0x80); trisc=OUTPUT; portb=tempb; //restore portb count=0x00; }
  9. Hello I am writing some code to interface a pic16f690 to a 16X2 LCD. I define the control pins in my header file using volatile bit pinEN @ PORTB . 4 etc. This compiles OK, but when I try to debug the code, the pins are not being updated when I set high or low to READ/WRITE or strobe the enable pin. Any suggestions.... adam
  10. Managed to sort it... I was using VSM to simulate a pic16f690, and had not setup the pin correctly for digital output.
  11. I am trying to toggle an LED using a Timer interrupt and the NOT operator, with the expression portb.4=~portb.4 When I run the code through the simulator the LED comes on and stays on. Could someone please explain what I am doing wrong. adam
×
×
  • Create New...