|
|
View previous topic :: View next topic |
Author |
Message |
skylinux
Joined: 02 Oct 2005 Posts: 2
|
Please help, what am I doing wrong. |
Posted: Sun Oct 02, 2005 9:17 pm |
|
|
I'm attempting to build a robot and have some problems with CCS sleep at the end.
My program runs the way I want it but it will sleep at the end. I have cut out most code and it still does it. Please help, I don't see my error.
Code: | #include <16F628A.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC, NOPUT, NOPROTECT, NOBROWNOUT, NOMCLR, NOLVP, NOCPD
/*
Sumo Bot
This bot will search an oponent, find it and push it out of the ring.
*/
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_vref(FALSE);
setup_comparator(NC_NC_NC_NC); //Comparators off
set_tris_a(0); //PORTA all Output
set_tris_b(0x07); //Port B 0-3 Input, 4-7 Output
port_b_pullups(TRUE); //Enable PORTB pullups
delay_ms(500); //Startup Delay
while(TRUE)
{
output_low(PIN_A0); //This will turn the LED on?
delay_ms(200);
output_high(PIN_A0); //This should turn the LED off?
}
} |
I currently have a LED connected to PIN_A0, it turn on and that's it. I don't get it, please help. |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sun Oct 02, 2005 9:46 pm |
|
|
You are turning the LED off immideately after you turn it on. Add a delay after you output_high(PIN_A0).
Code: |
while(TRUE)
{
output_low(PIN_A0); //This will turn the LED on?
delay_ms(200);
output_high(PIN_A0); //This should turn the LED off?
delay_ms(200); // ### ADD THIS
}
|
|
|
|
Ttelma Guest
|
|
Posted: Mon Oct 03, 2005 5:03 am |
|
|
You are actually sitting in a loop, with pin_a0, pulled permanently low. It'll go high for just a couple of machine cycles, with the 'output-high_ instruction, and then the jump back to the output_low instruction. Now Kender, has pointed out, that to get it to visibly 'flash', you will need the second delay, to extend the 'off' time.
As a seperate comment, what resistor value have you got to limit current to the LED, and what type of LED is it?. If you have a LED directly connected, and no limit resistor, you may well be overloading the chip, which could cause the code to really get screwed up when running...
Best Wishes |
|
|
skylinux
Joined: 02 Oct 2005 Posts: 2
|
|
Posted: Mon Oct 03, 2005 10:29 am |
|
|
I can't believe I did not see that, well that's where the MPLAB simulator was very helpfull.
Will the ICD-U40 allow me to do a line by line debug like MPLAB's simulator?
And if so, is the ICD-U40 sold by CCS the best choice for a $ < $100 debugger or are there better alternatives? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 03, 2005 11:04 am |
|
|
Remember that the CCS debugger requires PCW or PCWH.
You can't use it with MPLAB. |
|
|
mcafzap
Joined: 07 Sep 2003 Posts: 46 Location: Manchester, UK
|
|
Posted: Mon Oct 03, 2005 12:50 pm |
|
|
Yes, the ICDU40 works as a good debugger if you use it with PCWH. I believe you can load it with code to have it behave like an ICD 2.
I still have a Microchip ICD 2 and this is the cheapest way to go because MPLAB is free. However, I prefer the interface that CCS provides.
Steve |
|
|
Guest
|
|
Posted: Sun Oct 09, 2005 7:27 pm |
|
|
Ok, I tried it and of course the missing delay kept it from blinking.
My original problem solved itself. I sync my laptop's programming directory to my desktop's programming folder every time they "see" each other. Something must have gone wrong since the new code section with the problem was gone. I rewrote it and it works almost perfect.
My bot seeks a target, pushes it out of the ring, once it disappears from sensor it will go back to finding targets, turning the way the target was last seen. The turning towards the last target part does not always work right but I'm getting there.
Quote: | Remember that the CCS debugger requires PCW or PCWH.
You can't use it with MPLAB. |
Yes, I know that but I like it easy , I have used ASM and feel that I have reached my limit with it. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|