Hi,
I just tested the port D second bit and it works
just well with the following right after the main:
#include "config.h"
static void led_on(void)
{
TRISDbits.TRISD2 = 0;
LATDbits.LATD2 = 0;
}
...
int main(void)
{
led_on(); while (1) ;
return 0;
}
here is the content of my config.h:
/*
** Made by fabien le mentec <[email protected]>
**
** Started on Sun Nov 30 04:42:01 2008 texane
** Last update Sun Nov 30 05:18:38 2008 texane
*/
#ifndef CONFIG_H_INCLUDED
# define CONFIG_H_INCLUDED
#ifdef _SDCC
# define CONFIG(k, n) code static char at __ ## k _ ## k = n
/* bits value meaning
5 0 clock comes from the primary osc block, no prescale
4-3 3 system clock postscaler (none)
2-0 0 prescaler (none)
*/
CONFIG(CONFIG1L, 0x10);
/* bits value meaning
7 0 osc switchover mode disabled
6 0 failsafe clock mon disabled
3-0 a osc selection: internal osc used, usb use xt
*/
CONFIG(CONFIG1H, 0x0a);
CONFIG(CONFIG2L, 0x00);
/* bits value meaning
0 0 wdt disabled
*/
CONFIG(CONFIG2H, 0x00);
/* bits value meaning
1 0 portb<4:0> are digital io
0 1 ccp2 mx with rc1
*/
CONFIG(CONFIG3H, 0x01);
/* bits value meaning
7 1 background debugger disabled (rb6,7 are general io pins)
6 0 extended instruction disabled
*/
CONFIG(CONFIG4L, 0x80);
#endif /* _SDCC */
#endif /* ! CONFIG_H_INCLUDED */
I hope it helps,
Fabien.
On Sun, Jan 11, 2009 at 10:39 AM, Vaclav Peroutka <[email protected]>wrote:
> Hi Kusti,
>
> are you sure that you have proper connection of wires to that pin ? And pin
> is not shorted to anything else?
>
> AFAIK PORTD2 bit has no other functionality to 1 and 0 bits.
>
> If you remove anything else and make simplest code ( just Z = 0, delay();
> Z= 1; delay() )- it does not work, too ?
>
> Vaclav
>
> > ----------------------------------------
> > Hi,
> >
> > this is not the right list, I know, but at very least I hope someone
> > will direct me to a list likely to produce some insight to my problem.
> >
> > I using PIC18F4550 and so far I've got remarkable little problems.
> >
> > However I've not been able to control the bit 2 of PORT D.
> >
> > I'm observing the direct outputs from the MCU pin with oscilloscope.
> >
> > I've looked at the code produced by SDCC and it makes perfect sence.
> >
> > So I'm thinking this is something to do with some PIC18 configuration
> > or
> > some registers not being set up properly.
> >
> > I've been up and down the datasheet but have not found anything
> > that would get me further.
> >
> > My code is as follows:
> >
> > #define STEP_X PORTDbits.RD0
> > #define STEP_X_TRIS TRISDbits.TRISD0
> >
> > #define STEP_Y PORTDbits.RD1
> > #define STEP_Y_TRIS TRISDbits.TRISD1
> >
> > #define STEP_Z PORTDbits.RD2
> > #define STEP_Z_TRIS TRISDbits.TRISD2
> >
> > <snip>
> >
> > STEP_X_TRIS = 0;
> > STEP_Y_TRIS = 0;
> > STEP_Z_TRIS = 0;
> > <snip>
> >
> > for (;;) {
> > STEP_X = 0;
> > STEP_Y = 0;
> > STEP_Z = 0;
> > LED_PIN = 0;
> > delay_ms(2);
> >
> > STEP_X = 1;
> > STEP_Y = 1;
> > STEP_Z = 1;
> >
> > LED_PIN = 1;
> > delay_ms(2);
> >
> > }
> >
> > br Kusti
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Check out the new SourceForge.net Marketplace.
> > It is the best place to buy or sell services for
> > just about anything Open Source.
> > http://p.sf.net/sfu/Xq1LFB
> > _______________________________________________
> > Sdcc-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/sdcc-user
> >
> >
> >
>
>
> ------------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It is the best place to buy or sell services for
> just about anything Open Source.
> http://p.sf.net/sfu/Xq1LFB
> _______________________________________________
> Sdcc-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user