PDA

View Full Version : blink a single led



MINHLE
- 27th November 2016, 13:09
hi,
can any friend help this situation
the program had run well for some years, now this fail even if to blink a single led on a breadboard.
i have tried several chips: 16f 676, 876,,877a, 18f2455, 26k20... all the same bad result?
the programmer is just updated to 5.1 last night
thank for your help

i post a program here (pic18f26k20):
-------------------------------------------------------

INCLUDE "h:\AllDigital.pbp"
ASM
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
OSCCON = $70 Internal oscillator is set to 16MHz $62 ' 8mhz--- '; Primary Clock is selected as system clock.
OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
define osc 64
ADCON0 = 0
CM1CON0.7 = 0
CM2CON0.7 = 0
portb = 0
latb = 0
trisb = 0
'------------------------------------------

program:
portb = $ff
pause 1000
portb = 0
pause 1000
GOTO program
'==============================================

end

Demon
- 27th November 2016, 14:42
Upper case defines.

MINHLE
- 28th November 2016, 00:56
tks for your rePLY,
it is not the problem of program, nor breadboard? nor programmer?- it is suddenly dead
note that is well simulated in the proteus sofware

Demon
- 28th November 2016, 01:19
If it is suddenly dead, I'd pay close attention to the breadboard connections and power supply.

You should also read up on READ MODIFY WRITE.
http://www.picbasic.co.uk/forum/showthread.php?t=21294&highlight=Read+modify+write

MINHLE
- 28th November 2016, 02:45
TKS for ur reply,
no way. power supply and every thing is ok
the chip was programmed a month ago is ok (on the bread board and on the circuit), just after last month, every thing is corrupted ( even on the sam breadboard connection or the same pcb)
i reprogram mplab and pbp but no help

towlerg
- 28th November 2016, 06:33
What has changed on the PC and programmer? In post#1 you said "programmer is just updated to 5.1 last night". if you mean that you updated the firmware in the programmer, then try reverting to the previous version.

BTW RMW hardly an issue with 1 sec between writes.

Art
- 28th November 2016, 09:22
The program writes the entire port anyway :D

MINHLE
- 28th November 2016, 10:35
tks all,
after several attempts during a month, i tried to update the programmer firmware just a day ago.

MINHLE
- 2nd December 2016, 21:42
HELLO,
HOW CAN I VERYFY a progrmmer be good or bad?
after reading the hex file from the chip,
the hex file from the compiler seems identical to that of re-reading from the chip.

in other articles in the forum also mentioned this.
such as mplab rewrite a new way of writing fuses

CONFIG FOSC = INTIO67, FCMEN = OFF, IESO = OFF
instead of
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H &..
when the compiler compile the pbp file which 1 is included
i add the second way to the beginnig of a program:
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H &..
is that the reason the program to be shut down?
any help i do appriciate,
thks

richard
- 2nd December 2016, 23:40
HOW CAN I VERYFY a progrmmer be good or bad?

erase "blank" the chip , verify chip is blank
reprogram chip , verify program against hex file

MINHLE
- 3rd December 2016, 00:30
TKS FOR YOUR REPLY,
I did it maytimes but in vain,

the chip was programmed before a month a go run well on both breadboard and pcb
but the chip programmed (the same program) later has not run at all on both breadboard and pcb
now program is reduce to a signle led to be easy to control but not run at all.
this happened some years ago but now i forgot how to fix it (nothing to fix as i remember) but now i have to find out the root of a problem

towlerg
- 3rd December 2016, 01:48
have you tried reverting to the previous version of programmer firmware?

MINHLE
- 3rd December 2016, 03:18
Thks,
yes, i did every thing to run but no way
one of the thing is the led on or off when my hand is getting closer to it (the whole surface p10 led dot matrix)

Dave
- 3rd December 2016, 20:38
Minhle, A rough schematic would be helpful....

MINHLE
- 4th December 2016, 02:05
TKS
i attach the schematic drawing from isis.
the program is similiar to the 1 above
this is the schematic on the breadboard.
the internal osc is used 64mhz
the leds r connected through 100 or 1k ohm resistors
when simulating on isis: osc is changed to 4mhz



8355

richard
- 4th December 2016, 04:36
I would not expect anyone who values their computer's integrity to open a "doc" file from an untrusted source.

make it a jpg,gig,png or some other safer format



ps what version of pbp are you using . that config section is way way old hat

Art
- 4th December 2016, 06:53
Maybe on breadboard the crystal didn’t start to oscillate.
Try licking your finger and touching one leg, then the other, then both.

Edit.. whoops.. uses internal osc.. can’t delete post.

MINHLE
- 4th December 2016, 10:49
tks for all

now i know how to send by pdf, here is the attachment
8356
i used pbp v 2.6

i used internal osc 64mhz or 4mhz
no external capacitors on the osc pins,
the same program that is programed into the chip ran before but now it does not ( on both pcb and breadboard)
i attach the program that is slighly changed the pause statement:

INCLUDE "h:\AllDigital.pbp"
ASM
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
OSCCON = $70 '$70 Internal oscillator is set to 16MHz $62 ' 8mhz--- '; Primary Clock is selected as system clock.
OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
define OSC 64
ADCON0 = 0
CM1CON0.7 = 0
CM2CON0.7 = 0
portb = 0
latb = 0
trisb = 0
'------------------------------------------
i var byte
m var byte
main_program:
gosub blink 'call suroutin to blink a led
GOTO main_program
'==============================================
blink:
high portb '= $ff ' light the led for acertain amount of time
for i = 0 to 100 'loop to maintain the led on
FOR M = 0 TO 10
pause 1
NEXT
NEXT
low portb '= 0 'tuen off the led for certain amount of time
for i = 0 to 50 'loop to maintain the led off
FOR M = 0 TO 10
pause 1
NEXT
NEXT
return
'-------------------------------------------
end

MINHLE
- 4th December 2016, 10:59
i do not under stand configuration is old hat and
internal osc can delete post?
can you explain clearly,
tks

Dave
- 4th December 2016, 15:00
Looking at the schematic, I believe the MCLR reset connection violates the Spec. The correct circuit can be found on page 53 of the processor spec. The power supply rise time needs to be within spec. or it will never reset properly.

MINHLE
- 5th December 2016, 01:14
tks Dave
i do not have 15k-40k resistor,however, i disable mclr in the conf: mclre_off_3h
but nothing happens, i check the resistors tomorrow,

richard
- 5th December 2016, 03:06
Your code has some issues



INCLUDE "h:\AllDigital.pbp" why ?
ASM
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
OSCCON = $70 '$70 Internal oscillator is set to 16MHz $62 ' 8mhz--- '; Primary Clock is selected as system clock.
OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
define OSC 64
ADCON0 = 0 why ?
CM1CON0.7 = 0 why ?
CM2CON0.7 = 0 why ?
portb = 0 why ?
latb = 0 why ?
trisb = 0 is this really what you want ?
'------------------------------------------
i var byte
m var byte
main_program:
gosub blink 'call suroutin to blink a led
GOTO main_program
'==============================================
blink:
high portb '= $ff ' light the led for acertain amount of time this is not a legitimate use of HIGH
for i = 0 to 100 'loop to maintain the led on
FOR M = 0 TO 10
pause 1
NEXT
NEXT
low portb '= 0 'tuen off the led for certain amount of time this is not a legitimate use of LOW
for i = 0 to 50 'loop to maintain the led off
FOR M = 0 TO 10
pause 1
NEXT
NEXT
return
'-------------------------------------------
end

I can't verify your config settings as I no longer use that ancient old complier [you could at least update to 2.6c]

assuming your config and osc settings are workable then this code is tested an works for me ,
1k r in series with led, vdd 5v 4.7k pullup on mclr



ASM
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
OSCCON = $70 '$70 Internal oscillator is set to 16MHz $62 ' 8mhz--- '; Primary Clock is selected as system clock.
OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
define OSC 64
ANSELH = 0


trisb=%11111110

pause 2000


'------------------------------------------
i var byte
m var byte
main_program:
gosub blink 'call subroutine to blink a led
GOTO main_program
'==============================================
blink:
LATB.0=1 ; light the led on portb.0 for a certain amount of time
for i = 0 to 100 'loop to maintain the led on
FOR M = 0 TO 10
pause 1
NEXT
NEXT

LATB.0=0 'turn off the led for certain amount of time
for i = 0 to 50 'loop to maintain the led off
FOR M = 0 TO 10
pause 1
NEXT
NEXT
return
'-------------------------------------------
end

MINHLE
- 7th December 2016, 10:32
HELLO rICHARD,

Thk for ur reply,
the code displayed there is for timer, interrupt, and digital conversion.
that run well for several years.
your code is also not run at all on my breadboard.
the ANSELH is not used in my code due to the fact the PBADEN_OFF_3H is off.
about the version of the pbp, it is not relevant to the fail i think so.
1 think i pay attention to is the effect of charge accumulated on the breadboard (run @64mhz). but the pcb no charge on it..
i replayed another small breadboard , but the situation has not been better.

Archangel
- 10th December 2016, 06:20
Suspect your breadboard if it is older than 1 year, the sockets corrode and become insulators.

define OSC 64 ' does NOT make the pic oscillate at 64 mhz, it simply adjusts PBP's timing to accomodate that speed, so if you are running at say 4mhz then whatever you expect to happen in 1 second will take 4/64 or 16 seconds to happen. I think your config will not allow 64mhz as you need PLL FOSC = HSPLL HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)

MINHLE
- 11th December 2016, 03:43
HELLO,
Tks for ur idea,
it is true that the breadboard is older than 1 year. but the
however, the same breadboard connection and pcb ( i design it and product it) the pic that was programmed a month before is ran perfectly now
but the same program is burned into the chip NOT RUN AT ALL now ON BOTH BREADBOARD AND PCB

about the osc @64mhz and 4mhz, r really different:
let's say
PAUSE 500 @64MHS OSC : the led blinks faster than
PAUSE 500 @4MHZ (by inspection)
i really do not know the pic runs @64mhz or not. but at this speed, it can handle 6-8 p10 led modules (in my case)
i include a short video that is on the market for several years that i had sold,
i try to upload but fail.
i will reload later

MINHLE
- 11th December 2016, 13:07
HELLO,
HERE IS THE LINK: https://youtu.be/BQnuAWE8r0c

last night i though when the breadboard becomes isolation (due to plug and unplug the chip may times)
so the zip socket on the programmer gets the same situation?

but the programmed chip (last month) runs well right now on the on both pcb and breadboard-
i can eliminate all off the situation then conclude that the programmer fails- but i check the code from the chip is ok (like the code compiled)
now i m like "a dog runs after its queue".

MINHLE
- 14th December 2016, 02:34
hello every body

finally the program runs as posted on the first post- nothing change- and just go back to another computer (complete format the system...) and run win xp- pbp version 5
tks for all

MINHLE
- 24th December 2016, 14:18
HI EVERYBODY

the problem came from the computer - but i have had no idea why the program did not run at all. the chip was burned perfect by the programmer-
the code is perfect (checking by inspection)- (the version of the pbp is irrelevant to the problem)

tks all for your help