Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

clockspeed 18f4520

Status
Not open for further replies.

Goos_E

New Member
I try to program a oic 18f4520, but i get stuck on the clocksetting (I think).
what happens when i program the chip it goes to the first setting of PORTD and then it stops.
I think it has something to do with the clocksettings or the configuration bits.
I tried it with waitms and with a loop both don't work.

Thanks in advanced,

Goos.
 
Define CONFIG1L = 0x00
Define CONFIG1H = 0x89
Define CONFIG2L = 0x1a
Define CONFIG2H = 0x00
Define CONFIG3L = 0x00
Define CONFIG3H = 0x83
Define CONFIG4L = 0xc0
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

TRISD = 0
main:
PORTD = 0
WaitMs 250
PORTD = 255
WaitMs 250
Goto main

This is my code.
I tried to switch over the portD 0 to portd 255 and all it does is execute the first portd assignment. That is al leds burning or no leds burning. ( i have swiched both portd commands)
 
Right..... Oshonsoft's simulator will take a day to do a "waitms 250"

At the top of your code insert...
Code:
DEFINE SIMULATION_WAITMS_VALUE = 1

Then the code will stop for a much shorter time When you use a REAL device you change it to..

Code:
DEFINE SIMULATION_WAITMS_VALUE = 0
 
I am using a real device. I think i am doing something wrong with the clocksettings or something in that direction. I am using no crystal and using the internal oscilator. If i delete the waitms in the code i got a somewhat darker leds. So i think that the code is running,
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    43.4 KB · Views: 347
I think i have found the problem. When I disable the /mclr pin selection to /mclr_off_3h the program works just fine.
 
I think i have found the problem. When I disable the /mclr pin selection to /mclr_off_3h the program works just fine.

You should have the MCLR pin tied to V+ through a 10k resistor when you're not using that pin. If you just leave it floating, the chip might mistake the fluctuation for a reset signal. It would help to see the schematic you are using.

Regards,
Matt
 
I haven't used a schematic yet. I am just expirementing. I would sure use a 10k resistor now. Is that the problem with mclr pin. I don't know.
 
If you're not following a basic ICSP schematic then no wonder it's not working! PICs tend to be very picky (no pun intended) about how they're connected. You really should read a datasheet and do some research before experimenting with microcontrollers. Otherwise you risk damaging them (and no, I'm not being over-dramatic here, I'm 100% serious).

But yes, chances are the reason it's not working is because you don't have MCLR tied to V+ with a resistor.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top