![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
I/O Q, using ER22 Board from Iosoft |
Posted: Thu Feb 03, 2005 4:55 pm |
|
|
Hi guys, wondering if anyone can help:
I have tried hooking up an LED to one if the I/O pins on my ER22 development board, and just adding this line of code, just to turn the LED on and off when it is running through the source code from iosoft.
output_low(PIN_C0);
delay_ms(5000);
output_high(PIN_C0);
delay_ms(5000);
output_low(PIN_C0);
However the LED does not turn on or off,
I have set up the LED in both active low, and active high ways, and still nothing although in the Active High set up the LED lights up after it goes through the code above and goes through the rest of the code.
I am confused, anyone help? |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Feb 03, 2005 6:25 pm |
|
|
Maybe the pin is configured as an input. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Fri Feb 04, 2005 5:46 am |
|
|
*EDIT*
Both posts removed by request of original author. |
|
![](templates/subSilver/images/spacer.gif) |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
|
Posted: Fri Feb 04, 2005 6:04 am |
|
|
Sorry, that was me, dnt know why it double posted
Anyone help? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 04, 2005 11:32 am |
|
|
It's unfortunate that you posted that as a guest, because I doubt
that you can login and delete the double-post as a guest.
In your original post you were trying to toggle pin C0.
You said you had an LED attached to that pin.
But in the code you posted above, you're toggling pin B0.
So maybe you just need to move the LED (and series resistor) to pin B0.
output_low (PIN_B0);
delay_ms(5000);
output_high (PIN_B0);
delay_ms(5000); |
|
![](templates/subSilver/images/spacer.gif) |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
|
Posted: Fri Feb 04, 2005 1:13 pm |
|
|
Good Point, maybe if a moderator reads this can they delete both posts, as i think i may have posted too much of the code aswell(copyright and all that)
I did have the LED on B0, i jus posted C0 as an example of the code i did.
i have just tried running the code to see what happens without adding my bit of code to light an LED, i have noticed that when it is running all the pins from B0-B7 are high anyway, so there is somewhere in the code setting them all to be outputs, i thought it might of been here:
Code: |
PORTA= 0xff;
PORTB = 0xff;
PORTC = 0;
PORTD = 0xff;
PORTE = 0xff;
LCD_E = 0;
|
but port A and Port C I/Os are all low when running normally.
earliar in the code there is:
Code: |
// Default TRIS values for I/O ports
// May be overriden by included files
#ifndef TRISA_VAL
#define TRISA_VAL 0x03 // Port A, bit 0 and 1 analog I/Ps
#endif
#ifndef TRISB_VAL
#define TRISB_VAL 0x20 // Port B, bit 5 pushbutton I/P
#endif
#ifndef TRISC_VAL
#define TRISC_VAL (ALL_IN) // Port C, RS232, i2c, etc
#endif
#ifndef TRISD_VAL
#define TRISD_VAL (ALL_IN) // Port D, data bus
#endif
#ifndef TRISE_VAL
#define TRISE_VAL (ALL_OUT) // Port E, NIC control lines
#endif
|
which sets A0, A1, and B5 to inputs
i have looked at the included files and cannot see any declarations relating to the I/O pins. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 04, 2005 3:57 pm |
|
|
Iosoft doesn't give very much information about their ER22 board,
at least on their website. They don't allow downloading of
the schematic.
My suggestion is that you try the simple test program shown below.
Don't try to put a test in the iosoft firmware until you can get this
simple program running.
I'm not sure how to program the 18F452 on the iosoft board.
They don't say. Is it ICSP (in-circuit programming) or do you
remove the chip from the board to do it ?
They also don't say what the crystal frequency is. They crystal
is the little oblong metal can next to the 18F452. I think
it might be 10 MHz, based on other comments on their website,
but you need to look at it to see what it really is.
I've setup the following program for a 10 MHz crystal.
(ie., using "HS" oscillator configuration and "clock = 10000000").
You should connect the anode (long lead) of the LED to pin C0
on the 18F452. The cathode (short lead) should go to a 330 ohm
resistor. The other side of the resistor should go to a ground pin
on the board. Hopefully they have labeled one such pin.
If you don't have a 330 ohm resistor, you can use anything from
270 to 470 ohms, or even slightly more outside that range.
Code: | #include <18F452.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 10000000)
//===================================
void main()
{
while(1)
{
output_high(PIN_C0);
delay_ms(500);
output_low(PIN_C0);
delay_ms(500);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
|
Posted: Fri Feb 04, 2005 4:24 pm |
|
|
Cheers for that, I have got that bit of code working, so i now have an LED flashing on C0
BTW, the board has an ICD connection, so i can program directly to it.
It is a 20MHz crystal.
I appreciate your help, i am off to read through all the code, there is something going on with the I/O declarations in the Iosoft source code that i will try and find. |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Feb 04, 2005 5:39 pm |
|
|
Is the LED on C0 or B0!!!! Make up your mind! If it is on C0 then this might be your problem:
Code: |
#ifndef TRISC_VAL
#define TRISC_VAL (ALL_IN) // Port C, RS232, i2c, etc
#endif
|
|
|
![](templates/subSilver/images/spacer.gif) |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
|
Posted: Sat Feb 05, 2005 3:00 pm |
|
|
Mark wrote: | Is the LED on C0 or B0!!!! Make up your mind! If it is on C0 then this might be your problem:
Code: |
#ifndef TRISC_VAL
#define TRISC_VAL (ALL_IN) // Port C, RS232, i2c, etc
#endif
|
|
I have tried on all pins, A0, B0-B7 and C0-C1, have changed the code u have above aswell. eg:
In the below code, A0,A1, B5 are inputs as is all of PORTC, i have changed this bit of code, to make all of PORTC Outputs, and still does not work.
Code: |
// Default TRIS values for I/O ports
// May be overriden by included files
#ifndef TRISA_VAL
#define TRISA_VAL 0x03 // Port A, bit 0 and 1 analog I/Ps
#endif
#ifndef TRISB_VAL
#define TRISB_VAL 0x20 // Port B, bit 5 pushbutton I/P
#endif
#ifndef TRISC_VAL
#define TRISC_VAL (ALL_IN) // Port C, RS232, i2c, etc
#endif
#ifndef TRISD_VAL
#define TRISD_VAL (ALL_IN) // Port D, data bus
#endif
#ifndef TRISE_VAL
#define TRISE_VAL (ALL_OUT) // Port E, NIC control lines
#endif |
I am Confused as later there is this bit of code:
Code: |
PORTA = 0xff;
PORTB = 0xff;
PORTC = 0;
PORTD = 0xff;
PORTE = 0xff;
LCD_E = 0; |
I have changed the above to:
Code: |
PORTA=0x00;
PORTB=0x00;
|
AND ALSO MOVED MY LED TO AFTER THIS BIT OF CODE WHICH COMES LATER :
Code: |
set_tris_a(TRISA_VAL);
set_tris_b(TRISB_VAL);
set_tris_c(TRISC_VAL);
set_tris_d(TRISD_VAL);
set_tris_e(TRISE_VAL);
|
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Feb 05, 2005 11:26 pm |
|
|
I wouldn't start arbitrarily changing the TRIS value for ports that
you're not even working on, such as ports A and B. Just stick with Port C.
The default value for TRISC is "ALL_IN". In the code that you posted,
I can't find any #define statement for ALL_IN. But almost certainly
it will be defined as 0xFF.
They do say that the default TRIS values may be over-ridden by code in
the include files. So you need to look in all the source code files for this
statement:
set_tris_c
They may have more than one instance of it. When you find it,
you need to change the parameter so the lowest bit = 0.
For example, suppose you find this:
set_tris_c(0xFF);
You should change it to this:
set_tris_c(0xFE);
By doing so, you're making Pin C0 into an output pin.
Also, mark the change with a comment. Example:
set_tris_c(0xFE); // LG 2-5-05 Made C0 into an output (was 0xFF) |
|
![](templates/subSilver/images/spacer.gif) |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
|
Posted: Mon Feb 07, 2005 3:55 pm |
|
|
Top advice PCM programmer, many thanks!
Will let you know how everything goes |
|
![](templates/subSilver/images/spacer.gif) |
LouiseG
Joined: 03 Nov 2004 Posts: 17 Location: London...UK!
|
|
Posted: Tue Feb 08, 2005 4:25 pm |
|
|
Got it sorted now:
Changed the ALL OUT declaration in one of the included files, and moved my bit of code to flash the led after the TRIS assignment part.
Now i better get cracking with what i really want to do with the board! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|