Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] LEDs doesnt blink pic18f67k22

Status
Not open for further replies.

Raady Here

Full Member level 5
Full Member level 5
Joined
Jun 8, 2013
Messages
242
Helped
26
Reputation
52
Reaction score
26
Trophy points
28
Location
India
Visit site
Activity points
1,571
PIC18f67k22, MPLAB 8.8V

Hi,

I created a union of 48 bits, connected 48 LEDs to the 48 port pins and I am trying to send data to the port pins through function"TOPORT(BYTE cmd)" and trying to shift bits,

but I can observe blinking only from 0 to 31 led, from 32 to 47 doesn't work.

if i change 'cmd' from 'long int' to 'double' then bit shifting also doesn't work and 32 to 47 led doesn't work.

is there any limit for the buffer for these processors as it is 8 bit processor ?

Code:
typedef unsigned long int BYTE;
	
typedef union _display
{
	BYTE PORT;
	struct 
	{
		unsigned Z01:1;
		unsigned Z02:1;
		unsigned Z03:1;
		.....			
		unsigned Z47:1;
		unsigned Z48:1;
	};
} display_flags;	

void TOPORT(BYTE DT)
{
	LED_P.PORT 	= DT;
	LED01 		= LED_P.Z01;
	LED02		= LED_P.Z02;
	LED03		= LED_P.Z03;
        .......
        LED46		= LED_P.Z46;
	LED47		= LED_P.Z47;
	LED48		= LED_P.Z48;
	Delay100TCYx(100);
}

void main()
{
      unsigned int ih = 0;
	....
	while(1)
	{
		
		cmd = 0b000000000000000000000000000000000000000000000001;
		for(ih = 0;ih<48; ih++)
		{
			TOPORT(~cmd);
			cmd = cmd << 1;
		}
	}	
}
 

the bitwise shift operators only work with integer data types
as the PIC18 does nat have the long long int data type I think you need to have seperate code to deal with LEDs 0 to 31 and LEDs 32 to 47
Code:
for(ih = 0;ih<48; ih++)
	{
	if (ih < 32)
              {
              TOPORT(~cmd);
	      cmd = cmd << 1;
	      }
       else
              {
                 ...
              }
 
even if i don't apply the shifting it doesn't work

Code:
while(1)
{
        cmd = 0x000000000000;
        TOPORT(cmd);
        delay();
        cmd = 0xFFFFFFFFFFFF;
        TOPORT(cmd);
        delay();
}
only 0 to 31 LEDs are blinking.
 

Xc8 compiler assumes the highest int bits as 32 , mentioned in section 5.4 of the manual.
 

I am sending data splitting data in to 2 separate structures of 24 bits each.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top