The Godfather talking
You think I am funny guy huh?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 20, 2024, 12:30:29 00:30


Login with username, password and session length


Pages: [1]
Print
Author Topic: [Help] Proton simple program not working  (Read 5234 times)
0 Members and 1 Guest are viewing this topic.
max
Senior Member
****
Offline Offline

Posts: 314

Thank You
-Given: 1598
-Receive: 52


« on: October 26, 2012, 09:11:12 21:11 »

Hi friends
Here is a very simple led flashing program, when I program the chip with the generated hex file there is no activity, the led is off.

Device = 16F616

Config      IOSCFS_4MHZ, CP_ON, MCLRE_OFF, PWRTE_ON, WDT_OFF, INTOSCIO, BOR_ON

Declare Xtal = 4
Declare Create_Coff = On

Symbol LED = PORTC.3   

 TRISA = %11001111     
 PORTA = %00000000

 TRISC = %11000000     
 PORTC = %00000000

Loop:

 Toggle LED
 DelayMS 1000           
 
 GoTo Loop
Logged

Fate arrived and made the conscious unconscious It silenced the activity of life.
flo0319
Junior Member
**
Offline Offline

Posts: 81

Thank You
-Given: 7
-Receive: 17


« Reply #1 on: October 26, 2012, 10:09:19 22:09 »

Quote
Any device with analogue inputs will power up in analogue mode. If you intend to use them as
digital types you must set the pins to digital by using the following line of code: -
Declare All_Digital = True
This will set analogue pins to digital on any compatible device.

This is from Proton Compiler Manual.

If you want to use some pins like analogue you can modify ANSEL register (after Power On Reset, ANSEL is 0xFF) "1" means analogue pin and "0" means digital.



EDIT:
  I simulate your program with "'Declare ALL_DIGITAL = true" and with "ANSEL.7 = 0" and now work. you need to use just 1 instruction line

« Last Edit: October 26, 2012, 11:13:35 23:13 by flo0319 » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #2 on: October 26, 2012, 10:33:36 22:33 »

If you use PDS I think you must set all config registers to a known value, this has been said so many times.
To help you there are known tools to do this, Not to set them is just making a stick to beat yourself up with.

When you compiled the program ....
Did you not see the > Hint [line7] : Ensure that all fuses are placed in the config list, as.........ans so on...
« Last Edit: October 26, 2012, 10:39:50 22:39 by pickit2 » Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1196

Thank You
-Given: 541
-Receive: 408



« Reply #3 on: October 26, 2012, 10:49:47 22:49 »

Turn off the power up timer I find this sometimes mess's things up
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
flo0319
Junior Member
**
Offline Offline

Posts: 81

Thank You
-Given: 7
-Receive: 17


« Reply #4 on: October 26, 2012, 11:22:49 23:22 »

Turn off the power up timer I find this sometimes mess's things up

why?
Logged
towlerg
Senior Member
****
Offline Offline

Posts: 263

Thank You
-Given: 474
-Receive: 104

What is this for?


« Reply #5 on: October 26, 2012, 11:27:56 23:27 »

When you first start it's a pretty steep learning curve isn't it!

You were close, slightly modded code

Code:
'--------------------------------------------------------------------
'   FLASHER.BAS
'--------------------------------------------------------------------

Device = 16F616

;Config      IOSCFS_4MHZ, CP_ON, MCLRE_OFF, PWRTE_ON, WDT_OFF, INTOSCIO, BOR_ON

Declare Xtal = 4
Declare Create_Coff = On
Declare All_Digital = True

Symbol LED = PORTC.3   

 'TRISA = %11001111     ' TRISA set the state of APort
 'PORTA = %00000000     ' PORTA is the data either read or write

 TRISC = %00000000     
 'PORTC = %00000000   

Loop:

 Toggle LED
 DelayMS 1000           
 
 GoTo Loop

So, in essense

Let the fuses default untill you need to change them.
The "All digital" takes care of the anologue stuff
You don't need to setup the A port
You don't need the PORTC command to write, the Toggle LED will do that for you.

Rgds
Logged

Win 7 Ult x64 SP1 on HP2570p
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC