Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 04, 2016, 09:09:55 09:09


Login with username, password and session length


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

Posts: 223

Thank You
-Given: 602
-Receive: 32


« on: October 26, 2012, 10:11:12 22: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: 82

Thank You
-Given: 7
-Receive: 16


« Reply #1 on: October 26, 2012, 11:09:19 23: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 27, 2012, 12:13:35 00:13 by flo0319 » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #2 on: October 26, 2012, 11:33:36 23: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, 11:39:50 23:39 by pickit2 » Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 976

Thank You
-Given: 197
-Receive: 344



« Reply #3 on: October 26, 2012, 11:49:47 23: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: 82

Thank You
-Given: 7
-Receive: 16


« Reply #4 on: October 27, 2012, 12:22:49 00:22 »

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

why?
Logged
towlerg
V.I.P
Active Member
*****
Offline Offline

Posts: 136

Thank You
-Given: 282
-Receive: 48

What is this for?


« Reply #5 on: October 27, 2012, 12:27:56 00: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 x86 SP1 on HP6910p
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