CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I/O Q, using ER22 Board from Iosoft

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

I/O Q, using ER22 Board from Iosoft
PostPosted: Thu Feb 03, 2005 4:55 pm     Reply with quote

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?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 03, 2005 6:25 pm     Reply with quote

Maybe the pin is configured as an input.
Guest








PostPosted: Fri Feb 04, 2005 5:46 am     Reply with quote

*EDIT*

Both posts removed by request of original author.
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 04, 2005 6:04 am     Reply with quote

Sorry, that was me, dnt know why it double posted Embarassed

Anyone help?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 04, 2005 11:32 am     Reply with quote

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);
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 04, 2005 1:13 pm     Reply with quote

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.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 04, 2005 3:57 pm     Reply with quote

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);
  }

}
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 04, 2005 4:24 pm     Reply with quote

Cheers for that, I have got that bit of code working, so i now have an LED flashing on C0 Smile

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.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 04, 2005 5:39 pm     Reply with quote

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
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

PostPosted: Sat Feb 05, 2005 3:00 pm     Reply with quote

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);

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 05, 2005 11:26 pm     Reply with quote

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)
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 07, 2005 3:55 pm     Reply with quote

Top advice PCM programmer, many thanks!

Will let you know how everything goes
LouiseG



Joined: 03 Nov 2004
Posts: 17
Location: London...UK!

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 08, 2005 4:25 pm     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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