Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About SLSL

  • Rank
  1. This present C2C compiler I'm using came with my "C for PIC" CD-ROM from Matrix Multimedia a couple of months ago. Yes, I will be getting the new C2C compiler. In fact, I've already downloaded the newest compiler, but haven't had the chance to play around with it yet. Soon, soon..... SLSL
  2. PROBLEM SOLVED!!! (I HOPE!) My program and hardware were fine after all. I solved the problem by fluke today. I was so frustrated after so many weeks of getting stuck that I told myself "I'm gonna try and click on every single setting on the PIC programmer and if it blows, bloody ####, so be it!!". I am using the "PICALL" programmer (there's a webpage for it somewhere - do a search). In my frustrations today, I just happened to click on an option called "Backgr. Debugger", which I believe is part of the Configuration Word. And everything now works like a breeze!! To be honest, I still haven't the slightest clue what on earth "Backgr. Debugger" is, but I'm gonna find out somehow. I'm still very much a beginner. I hope this things holds......if not, I'll be back again with more baffling questions. Thanks to all who have replied and tried to help....and so sorry for the bother! SLSL
  3. Good idea, Pavel.....I have include the asm file below. It is the same example as above, except that I'm flashing the first 3 LEDs of PORTC this time. Sorry that I can't really comment on this asm file because I know nuts about assembly. Does the asm file look OK? There is something else I discovered today. Most of the time, when I power up the circuit, it doesn't work well. There were once or twice when it did work. Feels like there is some power-up reset affecting the chip. (My power supply has been used successfully on the PIC16F84A, so I'm sure its OK). My PIC16F877 circuit is pretty simple, just with LEDs directly connected to the ports via current limiting resistors (of course the crystal and stabilising capacitors are included too). ; This file was generated by C2C-plus compiler version 4.00.7e include "C:\Program Files\MPLAB\P16f877.inc" ;Variables ***************************************** _i_delay equ 0x70 PORTB equ 0x06 PORTD equ 0x08 TRISA equ 0x85 TRISC equ 0x87 TRISE equ 0x89 STATUS equ 0x03 ORG 0 clrf PCLATH goto startcode startcode bsf ADCON1 clrf TRISB clrf TRISD clrf STATUS, D'5' bcf STATUS, RP0 clrf PORTB clrf PORTD clrf PORTC call _delay bcf PCLATH, 3 bcf PCLATH, 4 bcf STATUS, RP0 bcf STATUS, RP1 clrf PORTC call _delay bcf PCLATH, 3 bcf PCLATH, 4 bcf STATUS, RP0 bcf STATUS, RP1 clrf PORTC call _delay bcf PCLATH, 3 bcf PCLATH, 4 bcf STATUS, RP0 bcf STATUS, RP1 clrf end _delayend END
  4. Hi MSC, Thanks for the suggestion. Yes, I was careful to ensure that I did switch the target PIC to 16F877. I really don't know what's wrong. I've spent a few weeks troubleshooting this already. I've also checked my hardware and all seems OK. I take it that my program looks OK? SLSL PS: Bob, I think there are header files (and maybe inc. files too) written for the PIC16F877 in the "examples" page and the old forum.
  5. Hi Pavel, I have now used my own variables mapped on the tris and port registers. I thought I've got it right, but my PIC16F877 still doesn't run. Is the below correct? Or am I missing out something again? //DECLARE PORT char _PORTA@0x05 ; char _PORTB@0x06 ; char _PORTC@0x07 ; char _PORTD@0x08 ; char _PORTD@0x09 ; //DECLARE TRIS char _TRISA@0x85 ; char _TRISB@0x86 ; char _TRISC@0x87 ; char _TRISD@0x88 ; char _TRISE@0x89 ; char _ADCON1@0x9f ; char _STATUS@0x03 ; #define RP0 0x05 ; //DELAY LOOP void delay (void) { unsigned int i ; for (i=0; i<32000 ; i++) ; } void main (void) { set_bit (_STATUS, RP0) ; _ADCON1 = 0x06 ; // SWITCH OFF ADC _TRISA = 0 ; // DECLARE ALL AS OUTPUT _TRISB = 0 ; _TRISC = 0 ; _TRISD = 0 ; _TRISE = 0 ; clear_bit (_STATUS, RP0) ; _PORTA = 0 ; //SWITCH OFF ALL OUTPUTS _PORTB = 0 ; _PORTC = 0 ; _PORTD = 0 ; _PORTE = 0 ; while (1) { // RUN FIRST 3 LEDS ON PORT B _PORTB = 1 ; delay () ; _PORTB = 0 ; _PORTB = 2 ; delay () ; _PORTB = 0 ; _PORTB = 4 ; delay () ; _PORTB = 0 ; } } Regards, SLSL
  6. Hi! I guess this is a typical beginner's question, but I really can't find the solution anywhere and hope that someone can help. I started a few weeks ago with the 16F84A and successfully made it blink LEDs, control 7-segment LEDs, etc. Then last week, I moved on to the 16F877 with disastrous results! The first thing I tried to do was something simple like blink LEDs with the different ports.....which I couldn't even do. #pragma CLOCK_FREQ 10000000 void main (void) { set_bit (STATUS, RP0) ; TRISB = 0x00 ; //I tried set_tris_b and set_tris_c too clear_bit (STATUS, RP0) ; while (1) { output_high_port_b (0) ; //I have also used PORTB = 1 ; delay_ms (200) ; output_low_port_b (0) ; //I have also used PORTB = 0 ; output_high_port_b (1) ; delay_ms (200) ; output_low_port_b (1) ; output_high_port_b (2) ; delay_ms (200) ; output_low_port_b (2) ; // etc etc for b3 to b6..... output_high_port_b (7) ; delay_ms (200) ; output_high_port_b (7) ; } } The above prog worked beautifully with the 16F84A. However, with the 16F877, sometimes one LED would permanently light up (not blink), sometimes a few would light up (or blink briefly), sometimes something else unexpected would happen. I have checked the programming settings and the hardware and I'm convinced that all is well. I have left the wdt, brown_out reset, low-voltage programming and everthing else off. I am using a 10 mHz crystal with 33 pF capacitors. 5 VDC power comes in and is forked out to both the 16F877's Vdd pins. Both Vss pins are connected to the wire, then to ground. MCLR pin is connected to the 5 VDC supply via a 11K (10K + 1 K) resistor. I have used an ohmmeter to go through every since connection and all is in order. I am using C2C Version 4.00-something, which came with my 'C for PIC' CD-ROM. This narrows me down to the last two suspicions, ie. (1) I have a faulty chip, or (2) I have left out some important 16F877 initialisation/control program lines. What am I doing wrong? Or could this be just cruel retribution for all the naughty things I've done in my life? Please help....thanks. SLSL
  • Create New...