Problem of Driving Pin High in 16F1828

Status
Not open for further replies.

kahjoo

Junior Member level 2
Joined
Jul 23, 2012
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,456
Hi,

I in the middle of porting the MCU from 16F685 to 16F1828. Before transfer the old code to 18F1828, I've tried to run the MCU with the simple test program.
I'm using PICKit Eval board as to test the program. After program and run, found out the output pin of RC0 cannot drive the LED which only give about 1V output.

with the same code, change of config, I've run in 16F690 and there is no problem and LED able to be light up. Anything config that I miss out or wrong which I may overlook.

Below is original code of the 16F1828:-



 

Hi,

With these latest chips multifunction pins its easy to get things wrong when configuring them, however I think for PortC.0 its ok as you have done it, though it might be good practice to turn off the Analogue function in case you use any other Portc pins as Digital inputs.

Think your problem is that the ON delay is just 1ms and the OFF time 197ms, using the 4mhz osc you specify in Osccon - see Sim pictures.

Usually use this calculator for assembly delays.**broken link removed**


Edit, your code would not build because you missed off the ENDC to the CBLOCK directive

Code:
	cblock 0x20
	Delay1 ;Define two file registers for the
	Delay2 ; delay loop endc
	endc
 

Attachments

  • 2013-01-17 20_54_41-billyboy - MPLAB IDE v8.80 - Stopwatch.jpg
    65.5 KB · Views: 77
  • 2013-01-17 20_55_49-billyboy - MPLAB IDE v8.80 - Stopwatch.jpg
    64 KB · Views: 74

Hi,

Thanks. I've manage to trigger the output as required. Below is the modified code.





I've not look into detailed as I just want to test on the run. By the way, what compiler are you using as it's look new to me as I've never saw the tools with debug for the timer?

However, is that better way of switch back to bank0 when using "banksel" command?
Also, is that any way or good idea of making makro of the bank selection?

Thanks....
Kah Joo
 

That looks like the standard MPLAB stopwatch window to me.

'banksel' works in all cases but if you really have to optimize your code, there is a new instruction 'movlb x' which will directly select bank 'x' in a single step. I think MPLAB and MPLABX will automatically substitute movlb when you use the banksel directives, but obvioulsy only on the newer devices supporting that instruction, otherwise it sets/resets bits in the STATUS register instead.

Heed wp100's caution about multi-function pins, as you migrate to devices with more on-board peripherals it become important to select which the pin is internally connected to.

Brian.
 



Hi,

You can use the movlb D'1' ; bank1 as Brian mentions but if you are using various 16Fs it might be more compatible to use the banksel directive.
To return to bank 0 just use ' banksel 0 ' - bansel 1 etc does not work, you must specify a register.

The pictures shown are of the stopwatch used in MPlabs SIM.

Build your code, goto Debugger, select tool, MPLABSIM then you can either RUN or Single Step though your code.

However for a long delay you really want to 'run' over it, so on your line of code Right click and Set a Breakpoint before and after the delay.

You then Start the STOPWATCH and set it to 4mhz , run to the first breakpoint, zero the stopwatch, Run to the second breakpoint to find your delay time.

You can do many other things using the Watch Windows to see how you code changes the system and user registers etc etc
 

Hi,

Thanks for the information. Will try it soon. Thanks again.

Kah Joo
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…