Revision: 1644
Author: sebastien.lelong
Date: Sun Jan 31 02:35:26 2010
Log: test tris/port on 18f4550
http://code.google.com/p/jallib/source/detail?r=1644
Added:
/trunk/test/unittest/18f4550_tris_port.jalt
=======================================
--- /dev/null
+++ /trunk/test/unittest/18f4550_tris_port.jalt Sun Jan 31 02:35:26 2010
@@ -0,0 +1,209 @@
+-- Title: unittest to check pin directions and levels on 18f4550
+-- Author: Sebastien Lelong, Copyright (c) 2010, all rights reserved.
+-- Adapted-by:
+-- Compiler: 2.4m
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: test all PORT and TRIS
+--
+
+;@jallib section pic
+include 18f4550
+pragma target OSC HS
+pragma target clock 20_000_000
+pragma target WDT disabled
+enable_digital_io()
+
+;@jallib section self_test
+include unittest
+var byte a = 120
+asm nop
+test_byte(a) ;@assertEquals 120 test_test
+
+
+
+;@jallib section init
+PORTA_direction = all_input
+PORTB_direction = all_input
+PORTC_direction = all_input
+PORTD_direction = all_input
+PORTE_direction = all_input
+PORTA = low
+PORTB = low
+PORTC = low
+PORTD = low
+PORTE = low
+
+test_byte(PORTA) ;@assertEquals 255 test_porta_low
+test_byte(TRISA) ;@assertEquals 255 test_trisa_all_input
+test_byte(PORTB) ;@assertEquals 255 test_portb_low
+test_byte(TRISB) ;@assertEquals 255 test_trisb_all_input
+test_byte(PORTC) ;@assertEquals 255 test_portc_low
+test_byte(TRISC) ;@assertEquals 255 test_trisc_all_input
+test_byte(PORTD) ;@assertEquals 255 test_portd_low
+test_byte(TRISD) ;@assertEquals 255 test_trisd_all_input
+test_byte(PORTE) ;@assertEquals 255 test_porte_low
+test_byte(TRISE) ;@assertEquals 255 test_trise_all_input
+
+;@jallib testcase test_trisa_porta
+;@jallib use pic
+;@jallib use self_test
+;@jallib use init
+-- TRISA test (no RA7, PORTA[7] is always 1)
+pin_A0_direction = output
+test_byte(TRISA) ;@assertEquals 254 test_pina0_output
+pin_A6_direction = output
+test_byte(TRISA) ;@assertEquals 190 test_pina6_output
+pin_A1_direction = output
+test_byte(TRISA) ;@assertEquals 188 test_pina1_output
+pin_A5_direction = output
+test_byte(TRISA) ;@assertEquals 156 test_pina5_output
+pin_A2_direction = output
+test_byte(TRISA) ;@assertEquals 152 test_pina2_output
+pin_A4_direction = output
+test_byte(TRISA) ;@assertEquals 136 test_pina4_output
+pin_A3_direction = output
+test_byte(TRISA) ;@assertEquals 128 test_pina3_output
+-- PORTA test
+pin_A0 = high
+test_byte(PORTA) ;@assertEquals 0x81 test_pina0_high
+pin_A1 = high
+test_byte(PORTA) ;@assertEquals 0x83 test_pina1_high
+pin_A2 = high
+test_byte(PORTA) ;@assertEquals 0x87 test_pina2_high
+pin_A3 = high
+test_byte(PORTA) ;@assertEquals 0x8F test_pina3_high
+pin_A4 = high
+test_byte(PORTA) ;@assertEquals 0x9F test_pina4_high
+pin_A5 = high
+test_byte(PORTA) ;@assertEquals 0xBF test_pina5_high
+pin_A6 = high
+test_byte(PORTA) ;@assertEquals 0xFF test_pina6_high
+
+;@jallib testcase test_trisb_portb
+;@jallib use pic
+;@jallib use self_test
+;@jallib use init
+-- TRISB test
+pin_B0_direction = output
+test_byte(TRISB) ;@assertEquals 254 test_pinb0_output
+pin_B6_direction = output
+test_byte(TRISB) ;@assertEquals 190 test_pinb6_output
+pin_B1_direction = output
+test_byte(TRISB) ;@assertEquals 188 test_pinb1_output
+pin_B5_direction = output
+test_byte(TRISB) ;@assertEquals 156 test_pinb5_output
+pin_B2_direction = output
+test_byte(TRISB) ;@assertEquals 152 test_pinb2_output
+pin_B4_direction = output
+test_byte(TRISB) ;@assertEquals 136 test_pinb4_output
+pin_B3_direction = output
+test_byte(TRISB) ;@assertEquals 128 test_pinb3_output
+pin_B7_direction = output
+test_byte(TRISB) ;@assertEquals 0 test_pinb7_output
+-- PORTB test
+pin_B0 = high
+test_byte(PORTB) ;@assertEquals 0x01 test_pinb0_high
+pin_B1 = high
+test_byte(PORTB) ;@assertEquals 0x03 test_pinb1_high
+pin_B2 = high
+test_byte(PORTB) ;@assertEquals 0x07 test_pinb2_high
+pin_B3 = high
+test_byte(PORTB) ;@assertEquals 0x0F test_pinb3_high
+pin_B4 = high
+test_byte(PORTB) ;@assertEquals 0x1F test_pinb4_high
+pin_B5 = high
+test_byte(PORTB) ;@assertEquals 0x3F test_pinb5_high
+pin_B6 = high
+test_byte(PORTB) ;@assertEquals 0x7F test_pinb6_high
+pin_B7 = high
+test_byte(PORTB) ;@assertEquals 0xFF test_pinb7_high
+
+;@jallib testcase test_trisc_portc
+;@jallib use pic
+;@jallib use self_test
+;@jallib use init
+-- TRISC test (no C3, C4/C5 always input)
+pin_C0_direction = output
+test_byte(TRISC) ;@assertEquals 254 test_pinc0_output
+pin_C6_direction = output
+test_byte(TRISC) ;@assertEquals 190 test_pinc6_output
+pin_C1_direction = output
+test_byte(TRISC) ;@assertEquals 188 test_pinc1_output
+pin_C2_direction = output
+test_byte(TRISC) ;@assertEquals 184 test_pinc2_output
+pin_C7_direction = output
+test_byte(TRISC) ;@assertEquals 56 test_pinc7_output
+-- PORTC test
+pin_C0 = high
+test_byte(PORTC) ;@assertEquals 0x39 test_pinc0_high
+pin_C1 = high
+test_byte(PORTC) ;@assertEquals 0x3B test_pinc1_high
+pin_C2 = high
+test_byte(PORTC) ;@assertEquals 0x3F test_pinc2_high
+pin_C6 = high
+test_byte(PORTC) ;@assertEquals 0x7F test_pinc6_high
+pin_C7 = high
+test_byte(PORTC) ;@assertEquals 0xFF test_pinc7_high
+
+;@jallib testcase test_trisd_portd
+;@jallib use pic
+;@jallib use self_test
+;@jallib use init
+-- TRISD test
+pin_D0_direction = output
+test_byte(TRISD) ;@assertEquals 254 test_pind0_output
+pin_D6_direction = output
+test_byte(TRISD) ;@assertEquals 190 test_pind6_output
+pin_D1_direction = output
+test_byte(TRISD) ;@assertEquals 188 test_pind1_output
+pin_D5_direction = output
+test_byte(TRISD) ;@assertEquals 156 test_pind5_output
+pin_D2_direction = output
+test_byte(TRISD) ;@assertEquals 152 test_pind2_output
+pin_D4_direction = output
+test_byte(TRISD) ;@assertEquals 136 test_pind4_output
+pin_D3_direction = output
+test_byte(TRISD) ;@assertEquals 128 test_pind3_output
+pin_D7_direction = output
+test_byte(TRISD) ;@assertEquals 0 test_pind7_output
+-- PORTD test
+pin_D0 = high
+test_byte(PORTD) ;@assertEquals 0x01 test_pind0_high
+pin_D1 = high
+test_byte(PORTD) ;@assertEquals 0x03 test_pind1_high
+pin_D2 = high
+test_byte(PORTD) ;@assertEquals 0x07 test_pind2_high
+pin_D3 = high
+test_byte(PORTD) ;@assertEquals 0x0F test_pind3_high
+pin_D4 = high
+test_byte(PORTD) ;@assertEquals 0x1F test_pind4_high
+pin_D5 = high
+test_byte(PORTD) ;@assertEquals 0x3F test_pind5_high
+pin_D6 = high
+test_byte(PORTD) ;@assertEquals 0x7F test_pind6_high
+pin_D7 = high
+test_byte(PORTD) ;@assertEquals 0xFF test_pind7_high
+
+;@jallib testcase test_trise_porte
+;@jallib use pic
+;@jallib use self_test
+;@jallib use init
+-- TRISE test
+pin_E0_direction = output
+test_byte(TRISE) ;@assertEquals 254 test_pine0_output
+pin_E2_direction = output
+test_byte(TRISE) ;@assertEquals 250 test_pine1_output
+pin_E1_direction = output
+test_byte(TRISE) ;@assertEquals 248 test_pine2_output
+-- PORTE test
+pin_E0 = high
+test_byte(PORTE) ;@assertEquals 0xF9 test_pine0_high
+pin_E1 = high
+test_byte(PORTE) ;@assertEquals 0xFB test_pine1_high
+pin_E2 = high
+test_byte(PORTE) ;@assertEquals 0xFF test_pine2_high
+
+
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.